Created
April 13, 2022 17:59
-
-
Save the-dvlpr/3b7bcda89ef2a97c3c3f531420ee455e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void method(){ | |
try { | |
// do stuff | |
return redirectUser(true); | |
} catch (Exception e) { | |
return redirectUser(false); | |
} | |
} | |
public PageReference redirectUser(Boolean success){ | |
PageReference pageRef; | |
String woListViewId = '00B8c00000BrguBEAR'; | |
String oppsListViewId = '00B8c00000Brgr2EAB'; | |
if(success){ | |
if(workOrdersToInsert.size() > 0){ // All Work Orders | |
pageRef = new PageReference('/lightning/o/WorkOrder/list?filterName='+ woListViewId); | |
} else { // Single Work Order | |
pageRef = new PageReference('/'+ workOrdersToInsert[0].id); | |
} | |
} else { | |
if(selectedOpps.size() > 0){ // return to All Opportunities | |
pageRef = new PageReference('/lightning/o/Opportunity/list?filterName='+ oppsListViewId); | |
} else { // Single opportunity | |
pageRef = new PageReference('/'+ selectedOpps[0].id); | |
} | |
} | |
pageRef.setRedirect(true); | |
return pageRef; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment