The only option in Salesforce to place a Custom Button on a list view is to create a Visualforce
page and then call your required function from there.
But the issue I am facing is, I want to open a Primary tab in a console view from List view.
And the highlighted custom button is a Visualforce page.
<apex:page standardController="Case" extensions="NagsCreateCaseController" recordSetVar="test" action="{!resetToListView}">
<script>
window.postMessage('OpenCustomCreateCasePage','*');
</script>
</apex:page>
public class NagsCreateCaseController {
public NagsCreateCaseController(ApexPages.StandardController controller) {
System.debug('Empty constructor need for Manual Assignment Button');
}
public NagsCreateCaseController(ApexPages.StandardSetController standardController){
}
public PageReference resetToListView() {
return new ApexPages.Action('{!List}').invoke();
}
}
The issue is, I would not want to redirect anywhere when the button is clicked and just fire a postMessage
, so that I can listen to this post message and open console tabs from utilitybar
.
But as we know action
gets called even before the page gets rendered, so technically it just returns to the same list view page even before the <script>
gets called.
How do I call javscript right before action
gets called?
If I dont put action
, then it redirects the main page to empty page, which is not good.
I tried lightning actions, but that does not help as it wont get shown in List view.
Javascript actions also does not get on list view.
Tab0
and shows a blank page as shown on 2nd image.