-
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
Sinergify: Tailor Your Unique Business Needs into Salesforce and Jira Integration
Most businesses will agree that it is imperative to go the extra mile to deliver a personalized experience to their customers. But why is personalization…
A Guide To Writing Your Salesforce Administrator Resume
A Salesforce Administrator ensures companies experience the full potential of Salesforce and its technology. With an average starting annual salary of $79,000 and a 400% growth…
Why ISVs Must Strive Harder To Be On AppExchange?
Are you on Salesforce AppExchange? How many apps do you have on Salesforce AppExchange? If you are an ISV then you must be pretty aware…
Popular Salesforce Videos
Salesforce Flow Best Practices: Salesforce Flow Design Patterns
Salesforce Flow Design Patterns from Fundamentals to Mastery. In this session, we will talk about the top 10 Salesforce Flow best practices. We will talk…
How To Log Cases In Salesforce (Email-to-Case) | Salesforce Tutorial
How to log cases in Salesforce (Email-to-Case). In this video, the following points will be covered - 1. Enable Email-To-Case Get a brief introduction on…
How to Send a Pardot Email with Multiple Line Items | Salesforce
It is impossible to send a Pardot email that has a list of related records… or is it? In this session, Adam Erstelle uncovers strategies…