+ Start a Discussion
Rakesh Kumar 335Rakesh Kumar 335 

Can Validation rule fire when convert button or javascript button is pressed on lead?

There are two buttons on lead. 1.Convert, 2. Do not send
Clicking on convert opens a visual force page, while do not send is a java script button.
The requirement is, when either of these buttons are pressed a validation need to fire if the picklist value is selected as "unknown" for the field "cx interested?" on lead.  This field has 3 picklist values: Yes/No/unknown. The validation should fire only when the value is selected as "Unknow"
Now pls tell me what changes i need to make in visual force page and java script button.
Thanks
Raj VakatiRaj Vakati
Yes Rakesh, Please check "Require Validation for Converted Leads" on lead settings.
harika jharika j
Hi Rakesh,
Create a custom button on lead object by using the following js code snippet

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

if(cx_interested__c == "unknown"){
alert("*****cx_interested__c = "unknown"*****");
window.open('/apex/TestPage');

}
Mustafa JhabuawalaMustafa Jhabuawala
Hi Rakesh,

If clicking those buttons results into updating or inserting the record then the validation rule will be fired for sure.

In your case if clicking on button is opening a visual force page or a javascript is executed without inserting or updating the record then validation rule is not going to be fired.

If this is the case with you then you have to do the validation rule logic in your visual force page itself or in your javascript.

Hope you got my point.

Thanks,
Mustafa Jhabuawala
Technical Lead at Zen4orce (http://www.zen4orce.com)
Amol Salve 14Amol Salve 14
Hi Raksh,

Validation rule can fire if if the picklist value is selected as "unknown" for the field "cx interested?"  on click of "Do not send" button because this is javascript function you can write logic whille creating this button as 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

if(cx_interested__c == "unknown"){
alert("*****cx_interested__c = "unknown"*****");
window.open('/apex/TestPage');

}

But you can't fire validation rule on convert button as it open Visualforce page..

Thank you
Amol Salve
Salesforce Developer