Skip to content

Instantly share code, notes, and snippets.

@the-dvlpr
Created April 13, 2022 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-dvlpr/3b7bcda89ef2a97c3c3f531420ee455e to your computer and use it in GitHub Desktop.
Save the-dvlpr/3b7bcda89ef2a97c3c3f531420ee455e to your computer and use it in GitHub Desktop.
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