-
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
Unveiling the Top Trio: A Comprehensive Comparison of Three Most Effective Ways to Integrate Multiple Salesforce Instances
Salesforce has long been a dominant force in the CRM landscape, setting the gold standard despite its high costs and challenging implementation process. Its ability…
How Nonprofits Benefit from Salesforce and Capsule Services
Like many businesses, nonprofits also benefit from using a CRM for managing their funding. While Salesforce for small businesses focuses mainly on sales and growing…
Introduction to Salesforce: What is Salesforce and Why is it Popular?
What is Salesforce? Imagine having a platform that allows your business to manage everything in one place—customer relationships, sales, marketing, support, and more. That’s Salesforce,…
Popular Salesforce Videos
Salesforce CPQ Subscription Pricing
Configure Price Quote (CPQ) is a powerful sales tool that enables companies to produce accurate and highly configured sales quotes for customers — especially in…
Data Loader Alternative | Export and Import Data Using Salesforce Inspector
Find out how to export and import data using Salesforce Inspector, a very useful alternative to traditional data loader. watch this video and learn all…
Salesforce Interview Questions and Answers - For Freshers and Experienced Candidates
Learn most important Salesforce Interview Questions and Answers, asked at every interview. These Interview questions will be useful to all entry-level candidates, beginners, interns, and…