-
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
Top Considerations in Choosing the Right Salesforce Development Partner
Salesforce is the world’s leading and one of the most powerful CRM platforms that can redefine your digital journey, foster stronger brand loyalty and engagement,…
Salesforce Marketing Cloud Hacks You Must Try
For any Marketing Cloud professional, it is important to know the ins and outs of the product so it can be used to its full…
What is Salesforce Service Cloud
Salesforce is the most popular CRM-based service provider with numerous amazing products. It has the largest market share among CRMs and offers users great quality…
Popular Salesforce Videos
Integrate Salesforce and Active Directory Step by Step
The prospect of implementing Single Sign-on in your Salesforce org can seem daunting if you are unfamiliar with the process. In this live step-by-step demo…
Salesforce Beginner Interview Questions and Answers Full Length Video [2023]
Watch this video to get to know about Salesforce Beginner Interview Questions and Answers Full-Length Video [2023]. 00:00:00 Introduction 00:02:56 Sandbox 00:05:05 Process Builder 00:09:00…
Creation Of An Object In Salesforce | Salesforce Custom Objects
In this video, you will learn how to create a custom object in Salesforce, along with verification of the custom object in Salesforce. The following…