2

I want to enforce a condition according to which only verified Leads can get converted. Someone in my office gave me this formula :

AND( IsConverted , Verified_By_Admin__c = FALSE)

Where Verified_By_Admin__c is a checkbox having false as default.

Can anyone explain this to me?When this validation will occur?

2
  • Actually the validation to allow a lead to be converted wouldn't be that Isconverted and Verified by Admin both are true? Anyway we would need more information to help you better like where is this validation stored is this on a validation rule, on a Workflow? Process Builder? Commented Jul 6, 2016 at 13:02
  • No its the validation rule on Lead object only. Commented Jul 6, 2016 at 13:16

2 Answers 2

2

Lead conversion happens when the user clicks 'Convert Lead' in the UI or APEX issues the convertLead() method.

In either case, SFDC switches the Boolean field Lead.IsConverted to true and executes a DML event on Lead. Validation rules are executed once any before update triggers have completed.

As an aside, you could adopt SFDC convention and change the validation rule to:

AND(IsConverted,NOT(Verified_By_Admin__c))

as it is good practice reference checkbox/Boolean fields as implicitly having a true or false value and hence ONLY apply logical functions to them.

0

This is the execution context order explained in depth: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

So what will happen is that after all before triggers have executed validation rules will be checked. If none before triggers have modified verified by admin values, the values should be the same than the one it had when we started promoting the Lead.

So, if the lead wasn't verified by admin a Validation rule will raise due to a positive return on that formula and the lead won't be converted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .