-
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
Understanding About All the Salesforce Licenses and its Types
Salesforce Licenses Salesforce provides licenses for its users to access their company data. These licenses are available on the Company Information page. Developer Edition Organization…
How to Reach Better User Experience of a Salesforce App with a Webix-based Data Grid
Each growing business should continuously evolve since customers are becoming more demanding every day. As a result, software solutions are becoming obsolete very fast. The…
Everything You Need to Know about Salesforce Partner Portal
Implementing a robust partner portal becomes paramount as businesses strive to foster stronger partner relationships and expand their reach. Salesforce Partner Portal offers a powerful solution…
Popular Salesforce Videos
How Cyntexa Helped An Educational Firm | Salesforce Training
Here is a testimony of how Cyntexa helped an educational firm build a single place to keep all data. Swipe to know what the challenges…
How to Get A Part Time Salesforce Job
In this video, Brad discusses different techniques to convince a potential employer to offer you a part-time Salesforce position. This job option allows for additional…
Learn Apex Triggers Part 1 in Salesforce Development
In this video, you will be learning about Apex Triggers in Salesforce Development: We will be discussing the following things in this video: 1. What…