From a List Button or Visualforce Page, I wanna redirect to a ListView after. Common, right?
Life is great when we're dealing with Standard Controller: using view()
method.
What is the correct, documented, future-proof way to do this from a Standard Set Controller?
public PageReference back() {
//this seems so fragile and lightning-unfriendly: "/001?fcf=00B24000004cfLK"
SelectOption listViewOption = controller.getListViewOptions()[0];
PageReference pr = new PageReference('/' + SObjectType.Account.KeyPrefix);
pr.getParameters().put('fcf', listViewOption.getValue().left(15));
return pr;
}
I had some some ideas using ApexPages.Action but they caused kooky Internal Salesforce Errors:
public PageReference back() {
String expression = '{!URLFOR($Action.My__c.List, $ObjectType.My__c)}';
ApexPages.Action action = new ApexPages.Action(expression);
return action.invoke();
}