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
martinmacmartinmac 

Validation on the Convert button

Hi,

 

I need to introduce some simple validation on the Convert button on the Lead object.  I have two fields that each need to have a particular value (Lead Status must be Closed- Converted, and a custom picklist field Membership Level must a value chosen)

 

I understand that this can (should) be done using a trigger, but I'm afraid I don't know how to do that.

 

I work for a non-profit and we're implementing this ourselves, so would really appreciate some help please.

 

(My skills are confined to having attended the Admin Essentials course)

 

Thanks in advance

 

Martin

Edwin VijayEdwin Vijay

Hi,

 

I believe you need not create a trigger for this.. All you have to do is

 

  • Create a Visualforce Page. Check your conditions.
  • Override the Convert button with your visualforce page.
  • Do not worry if you are new to Visualforce, you have a lot of examples and an easy guide to get you started quickly.


Let me know if you need any help.

 

Cheers!!!

BharathwajBharathwaj

Hi,

 

just create a new custom button have

display type as: Button

behaviour:Execute JavaScript

OnClick JavaScript: enter your conditions and validations.

 

after specifying the conditions use this redirect statements:

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
if ( /*specify the conditions that you want to define*/)

{

my_URL="{!URLFOR($Action.Lead.Convert ,Lead.Id,[retURL=URLFOR( $Action.Lead.View, Lead.Id)])}";
window.parent.location.href = my_URL;
}
else
{
alert("Lead cannot be converted") ;
my_URL="{!URLFOR($Action.Lead.View, Lead.Id)}";
window.parent.location.href = my_URL;
}

 

this will allow you to customize the conditions for lead convertion

 

Regards,

Bharath