-
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
Integration of Salesforce with Google Calendar Using REST API
In this Blog, we are going to Integrate Salesforce with Google (Calendar, Email, Drive etc.) REST API. For this article, we are going to integrate…
How to setup an Einstein Chatbot in Salesforce?
In this article, we will discuss Einstein Chatbot and consider Omni-Channel, Lightning Knowledge Base, Embedded Service Deployment, and more. The first point to note: this…
Your 1st Step to become a Salesforce Certified Platform Developer 1 [Exam Notes]
Are you one among the many who endeavour to become a proficient Salesforce Developer? Then, this would be your first step after the completion of…
Popular Salesforce Videos
Non Technical but Want to Build Career in Salesforce?
In this video Shrey gave the answer of the following questions: 1. What is the next step after doing Certification in Salesforce Administrator? 2. How…
Salesforce is a fancy database
In this video, We will learn about the Salesforce Database (Data Modelling) in-depth in an interesting and fun way. I have divided this video into…
What are Global Picklists and Field Dependency in Salesforce? | How to Create Global Picklists?
In this video, Shrey is not only teaching but also demonstrating to you "What are Global Picklists & Field Dependency in Salesforce?". You will be…