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
Rakesh Kumar 335Rakesh Kumar 335 

Need Valudation rule to fire on a Visual force page

After convert button is pressed on lead, a visual force page fires.
I want a validation on this conversion vf  page & it should only fire when the value is 'unknown' on the below field.
Field: "Cx interested?" - values 'yes' or 'no' or 'unknown' on lead
Pls help
 
Pavit SiddhuPavit Siddhu

Hello, Create a custom button on object

User-added image

create formula according your condition
 

Sukanya BanekarSukanya Banekar
Hi Rakesh,
You need to create javascript custom button and check condition accordingly,
var field = field_Api;
e.g. if(field == 'yes' || field == ''No || field == 'unknown'){
window.location='/apex/vfpage';
}
else{
// close show some alert or do nothing
}
Let me know if this helps you to solve your problem.

Thanks,
Sukanya Banekar
Salesforce Developer

 
atul patil 7atul patil 7
Hello Rakesh,
    if you change your button type to Execute JavaScript, and run the  little script  before the redirect, that could work. Basic script flow would be: 

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

if(Cx interested = "unknown"){
window.open('/apex/<whatever your page is>');

}
else{
alert("Nice try, think again.");
}

thanx,
Atul Patil
Salesforce Developer
www.zen4orce.com
Rakesh Kumar 335Rakesh Kumar 335
Thanks guys. Let me explain in detail.
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