You need to sign in to do that
Don't have an account?
Afrose Ahamed
how to bypass validation when lead convert
Hello All,
When Lead convert if users choose Create New' then validation rule on lead needs to run if they choose 'Choose Existing' validation rule don't need to run. So i created check box on lead with unchecked.
After that i created trigger to bypass validation rule. But its running on both 'Create New' and 'Choose Existing' please refer the below code. Please help how can i acheive this.
Regards,
Afrose Ahamed M.G
When Lead convert if users choose Create New' then validation rule on lead needs to run if they choose 'Choose Existing' validation rule don't need to run. So i created check box on lead with unchecked.
Validation rule: AND(AfroseDev__By_Pass_Validation_Rule__c = True && ISBLANK(Email))
After that i created trigger to bypass validation rule. But its running on both 'Create New' and 'Choose Existing' please refer the below code. Please help how can i acheive this.
trigger LeadCurrencyTrigger on Lead ( Before Insert, Before Update, after insert,After Update) { list<id>OldAlloppid = new list<id>();//hold all opportunities ids in the list list<id>Convertedid = new list<id>();//hold currentConverted Opportunity Id in the list for(Opportunity op:[select id from Opportunity]){ OldAlloppid.add(op.id); } for(lead l:trigger.new){ Convertedid.add(l.convertedOpportunityId); // this condition will check the if current convertedoppid not in the existing opportunity records. if(OldAlloppid!=Convertedid) { System.debug('Convertedid'+Convertedid + 'oldMap'+OldAlloppid); if(l.IsConverted && trigger.isBefore){ System.debug('im inside'); l.AfroseDev__By_Pass_Validation_Rule__c = true; } } } }
Regards,
Afrose Ahamed M.G
Hey Afrose,
Kindly check this link which exactly matches your requirement :-
https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8KimSAF
Kindly mark it as the best answer if it helps.
Thanks & Regards,
Priya Ranjan
Hi @Priya,
Thanks for your reply. Actually i want to bypass the validation rule on the same object. when lead convert i want to bypass lead validation rule only when i choose existing Account.
Regards,
Afrose