function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Redirecting back to List View after some a mass action.

I have the following sequence I would like to do...


1) I have created a custom List button for a custom object.

2) This button redirects the user to another Visualforce page with a custom controller.   It takes an action on some of the custom objects depending on a certain status. 

3) After the action is complete I would like to return to the page where the custom list button was clicked by creating an appropriate PageReference.


I looked at using the StandardController, StandardSetController and URLFor objects to try to create the correct PageReference object, but I have had not luck.


This should be so simple.   Really the questions boils down to 'How do I create a URL to the default View for a custom object?'  






public String getReferer(){
   return ApexPages.currentPage().getHeaders().get('Referer');


Try this way:

Copy the list view page address from address bar and return that address in button click on your vf page. for example


return new PageReference(''); 


Thank you for the idea.   This seems to put my code in an endless loop.    The Referer is returning this 


The URL that I want looks like this:


But I don't want to hard-code a URL as the other post mentioned.  This needs to work in multiple sandboxes and in production.