function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
crichardsoncrichardson 

Validation around Converting Leads

Has anyone come up with code to override the Convert Lead button so that it can only execute when certain fields within the Lead record have been completed?
HeeseHeese
No, but I would look forward to seeing this. 
hudini3hudini3
I don't write code - but I've gotten pretty code at doing almost everything without it. What i would do here - create another record type. on 2nd record type (and corresponding page layout) input the convert button. on the first page, do NOT have the convert button. create workflow rules based on formula - to update the record type if all your fields are correctly filled in, otherwise there is no option for user to convert . .. .

BtormarBtormar

We have a piece of code in place that looks to see if the customer already exists or not - if not, it does not allow you to complete the conversion. I don't know how familiar you are with scontrols but I'd imagine you would do a javascript with the following logic:

IF Lead.fieldvalue1 == somestring

then

URLFOR($Action.Lead.Convert etc)

else

Error Message alert

URLFOR($Action.Lead.View.LeadID)

This would take the user back to the lead they tried to convert unless the condition in the IF statement is met.

If you need additional help with the code let me know and I can try to whip up something more detailed if needed.
whatAmIdoingwhatAmIdoing
I'd like to check to make sure my Lead.Industry field does not equal 'TBD' when the user clicks the 'Convert' button.  I created this s-control (as a snippet):
{!IF(ISPICKVAL( Lead.Industry , 'TBD'), URLFOR( $Action.Lead.View , Lead.Id), URLFOR($Action.Lead.Convert, Lead.Id ) )}

This (ideally) would just kick the user back to the Lead View screen if true, otherwise bring them to the Lead Convert screen.  Is this even close?

I know this isn't all I have to do, so I'm here to ask what to do next....  I have no clue.  I have this s-control created, now what?

(I know I'll need to add some error message as to why they couldn't convert the lead too, but baby steps here...)

Thanks.
Steve :-/Steve :-/
You can enforce Lead validation for required Contact and Account fields now.  You need to have SF Support to activate the feature on your SF.Org

Once it is activated go to:

  • Setup>
  • Leads>
  • Settings>
  • Enforce Validation and Triggers from Lead Convert