-
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
Salesforce Automation Testing: Best Practices to Follow
Salesforce comes with multiple OOTB (out-of-the-box) features that are customizable. Just like any complex, integrated solution, quality assurance and testing are important for Salesforce. The configuration…
Reimagine Your Salesforce CPQ Implementation On Demand
Most businesses today expect implementation resources to be On-Demand because of the agile development environment and overall cost factors that arise. A Salesforce implementation should…
Sales Forecasting Techniques That Are Incredibly Helpful | Salesforce Sales Cloud
Contrary to popular belief, there's more than just maths, logic, and/or science to sales forecasting. There's also a considerable amount of art involved in these…
Popular Salesforce Videos
Explore Our Salesforce Story
Explore the origins of Salesforce and how the Futureforce program came to be. Watch this video and do connect with us and share your experience…
How to Execute a SOQL Query in POSTMAN?
Watch this video to learn how to execute a SOQL Query in POSTMAN. If you have any doubts or questions, let us know in the…
COVID-19 Impact on The Automotive Industry -Digitization With Salesforce Can be a Solution
Coronavirus is expected to create a physical contactless environment with an increased thrust on online assessment and buying of vehicles. This is a huge shift…