-
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
Why Choose Salesforce CRM for the Hospitality Industry
Today, it's hard to imagine an industry with tougher competition than hospitality. Both small family-owned hotels and big-name international resort chains compete with each other…
Effective Ways To Use Salesforce For Customer Retention
Why is Customer Retention Important? When techniques are implemented by way of sales groups to hold clients, revenue is going up and fees go down.…
Introduction to Apex Unit Tests | The Developer Guide
In this blog, we will study test classes in apex, the best practices of test classes, and how to implement them. So, let’s begin with…
Popular Salesforce Videos
Salesforce Lightning Tutorial | Salesforce Developer Training for Beginners
This salesforce developer training for beginners video is a salesforce lightning tutorial where you will learn introduction to salesforce, salesforce components, salesforce lightning, lightning vs…
Winter 21 - Restrict Access to @AuraEnabled Apex Methods for Authenticated Users
Winter 21 - Restrict Access to @AuraEnabled Apex Methods for Authenticated Users The video explained the following Items: Action items to enable or disable the…
How to Become a Certified Salesforce Admin
It is predicted there will be 1.9m new Salesforce job openings by 2020. Consultants thinking of a career in IT should consider training in cloud…