+ Start a Discussion
Ravindar AdminRavindar Admin 

Javascript code in custom link

Hi, I am using Javascript code in Custom link to open a link or display Error message based on the condition .
Behavior= Execute Javascript
Content Source= Onclik javascript
 
if('{object__c.field1__c}' <> 'Z0' || '{object__c.field1__c}' <> 'Z4')
{
window.alert("Error Message");
}
else
{
window.open("https://xxxx.net/parmeter1={!object__c.field2}&parameter2={!object__c.field3}");
}

But, It is not working. Can anyone give suggestion



 
Raj VakatiRaj Vakati
Use this code
 
{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/41.0/apex.js")}

if('{!object__c.field1__c}' !== 'Z0' && '{!object__c.field1__c}' !== 'Z4') {
  alert('Error Message');
}
else {
window.open("https://xxxx.net/parmeter1={!object__c.field2__c}}&parameter2={!object__c.field3__c}}");
}