You need to sign in to do that
Don't have an account?
Margaret Fleischaker
Fire case assignment rule in Lightning Data Service
I'm creating a case in a custom lightning component using the Lightning Data Service. If I wanted the case assignment rules to fire, would I also have to have an apex class that uses the Database.DMLOptions? I'm assuming I can't use the following directly from the javascript controller?
//Fetching the assignment rules on case AssignmentRule AR = new AssignmentRule(); AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1]; //Creating the DMLOptions for "Assign using active assignment rules" checkbox Database.DMLOptions dmlOpts = new Database.DMLOptions(); dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id; Case newCase = new Case(Status = 'New') ; //Setting the DMLOption on Case instance newCase.setOptions(dmlOpts);
There is two Options here from my suggestion:
1. Use the After Insert Trigger in Case to keep the Lightning Data Service in your Lightning Component.
Trigger Examples:
https://www.salesforcexyz.com/category/salesforce/apex-trigger/
https://developer.secure.force.com/cookbook/recipe/running-case-assignment-rules-from-apex
https://www.forcetalks.com/blog/running-case-assignment-rules-from-salesforce-apex/
https://automationchampion.com/tag/run-case-assignment-rules-for-apex-trigger/
https://success.salesforce.com/apex/answers?id=90630000000D3SeAAK
2. Remove the LDS to insert the case record instead of that use the Server side Callback functionality(JS and Apex combination).From the JS pass the parameter to Apex to Insert the Case record and call this js function in button.
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj
All Answers
Or set from the apex trigger ..
There is two Options here from my suggestion:
1. Use the After Insert Trigger in Case to keep the Lightning Data Service in your Lightning Component.
Trigger Examples:
https://www.salesforcexyz.com/category/salesforce/apex-trigger/
https://developer.secure.force.com/cookbook/recipe/running-case-assignment-rules-from-apex
https://www.forcetalks.com/blog/running-case-assignment-rules-from-salesforce-apex/
https://automationchampion.com/tag/run-case-assignment-rules-for-apex-trigger/
https://success.salesforce.com/apex/answers?id=90630000000D3SeAAK
2. Remove the LDS to insert the case record instead of that use the Server side Callback functionality(JS and Apex combination).From the JS pass the parameter to Apex to Insert the Case record and call this js function in button.
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj