-
Need help on 'Fire approval' process on Lead merge?
There is an issue in my code while merging lead in Salesforce. The requirement is while merging lead I would like to stop the lead merge if the user is not the owner of the lead and then fire an approval process to owner of lead which is being merged. When the owner approves the lead to be merged, than the lead merge functionality can go on with the process. Below is my trigger on lead (which is working on before delete):-
trigger differentOwnerCheckTrigger on Lead (before delete) {
for(Lead lObj: trigger.Old){
if(lObj.OwnerID != UserInfo.getUserId())
{
lObj.addError('Sorry the lead cannot be deleted as you are not the owner of the lead.Please contact the owner of the lead to continue the process');
Approval.ProcessSubmitRequest submitApproval = new Approval.ProcessSubmitRequest();
submitApproval.setObjectId(lObj.id);
Approval.ProcessResult result = Approval.process(submitApproval);
}
}
}The trigger stops the lead to be merged and also the approval process is fired but is not assigned to any user.I know that I am missing something over here such that my approval process is firing, but it is not assigning to any user. Can anyone please help me out in this.
Thanks.
Log In to reply.
Popular Salesforce Blogs
Automate Call Logs Using RingCentral for Salesforce
Hi All, RingCentral one way solution for calling from Salesforce. This app is available on AppExchange, you just need to install it and make some administrator…
Do You Have Skills to Become a Salesforce Developer in 2024?
What is a Salesforce Developer? Salesforce developers are professionals who build functionalities in a sandbox with Visualforce or Apex before handing them over to the…
The Power of Salesforce Consulting Services for Successfully Meeting Business Needs
Time and again, Salesforce has proved itself as the best cloud CRM platform across the globe. What's more, it is also leading to successful CRM…
Popular Salesforce Videos
TrailheaDX 2020 Opening Film | Salesforce
Now more than ever, Trailblazers are using the Salesforce Platform from anywhere in the world to collaborate, innovate, make a change, and build a brighter…
Salesforce Tutorial For Beginners | Introduction To Salesforce | Salesforce Training
This video on Salesforce training will help you understand the easy and best tool for CRM and Branding. You will learn how to customize the…