-
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
What is CRM? A Beginner's Guide to Customer Relationship Management | Salesforce
What is CRM? CRM stands for Customer Relationship Management. The meaning of CRM has changed a lot over the years. CRM is a term that was initially…
Sharing Settings in Salesforce | The Ultimate Guide
Salesforce is a powerful Customer Relationship Management (CRM) platform that offers a wide range of features and functionalities to its users. One of the most…
How to Digitize Pharmaceutical Production with Salesforce
Following the pandemic, the pharmaceutical industry has been expanding and the companies are competing with each other, struggling to take a lead in the market.…
Popular Salesforce Videos
How To Use Javascript Editor In Formstack Part 1 - Learn Salesforce Series By Algoworks
Learn how to integrate Javascript editor in Formstack in this Salesforce tutorial brought to you by Algoworks. In this video, you will learn how to-…
Run Report With Filters from UiPath Studio | Salesforce
New features on Salesforce Activities Extention Package from UiPath MarketPlace: https://connect.uipath.com/marketplace/components/salesforce-activities-extention-package (0:40) Use complex object in the Query and Timeout part of the Setting to…
What is Apex? | Way to become a Salesforce Developer
Apex is a development platform for building software as a service (SaaS) applications on top of Salesforce's customer relationship management (CRM) functionality. Apex allows developers…