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
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}}");
}