2

I have a custom button on Opportunity for creation of a record with a predefined stage. I need to get back to the listview I started with if I cancel the operation

So I paste in the URL section:

    /lightning/o/Opportunity/new?defaultFieldValues=StageName=Prospect

I do it from a list view. And if I cancel the operation I need to return to the listview I started with. So far I was able to redirect to a certain listview by entering its API name:

&count=1&nooverride=1
&navigationLocation=LIST_VIEW
&backgroundContext=%2Flightning%2Fo%2FOpportunity%2Flist%3FfilterName%3D__Recent
&useRecordTypeCheck=1
&recordTypeId={!Opportunity.RecordTypeId}

instead of __Recent I can paste the API name of any other listview and after canceling it will redirect me there. But how to redirect to the listview I started with? I tried to enter currentPageUrl but it does't work, rather redirects me to an unexisting listview. Maybe I need to place any other parametr other then filterName?

1 Answer 1

1

In the url formula you can make use of the $Site merge fields (available on the 'Select Field Type' dropdown).

So your backgroundContext parameter could look like this:

&backgroundContext={! $Site.CurrentSiteUrl }

and that will show the current listview (or any other page where you came from) in the background, and also return the user to the current listview after clicking 'Cancel'.

As a final url, this is what is working for me (I removed the recordtype setting as I don't have recordtypes activated for Opportunities on this org):

/lightning/o/Opportunity/new?defaultFieldValues=StageName=Prospect
&count=1&nooverride=1
&navigationLocation=LIST_VIEW
&backgroundContext={!$Site.CurrentSiteUrl}
&useRecordTypeCheck=1
2
  • maybe I'm doing something wrong, but if I save &backgroundContext={! $Site.CurrentSiteUrl } instead of &backgroundContext=%2Flightning%2Fo%2FOpportunity%2Flist%3FfilterName%3D__Recent I have a blank page in the background Commented Oct 14, 2024 at 16:57
  • It works fine for me. Background is correct and also returning to the right list view after pressing Cancel. Do you click the button from the Lightning listview page? And also, I'm assuming you are not on Experience Cloud? Let me update my answer with the full url I'm using. Commented Oct 15, 2024 at 19:57

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.