0

I am kinda new person in JavaScript, please help me our here with small doubt

What I am missing here ........ I want to correct this one....

I am trying this :

if( {!Account.CID__c}){
    window.open( '{! SUBSTITUTE($Setup.CustomSetting__c.Link__c,"[#CID#]",Account.AnotherField__C)}');
}
else{
 window.open( '{! SUBSTITUTE($Setup.CustomSetting__c.Link__c,"[#CID#]",Account.CID__c )}')
}

GOT ERROR "Unexpected Token )"

Earlier I was having

window.open( '{!SUBSTITUTE($Setup.CustomSettings__c.Link__c,"[#CID#]",Account.CID__c)}');

And I just want to add one more Condition here i.e.

If(CID__C == null){
  // put another AnotherField__C in place of that.
}else{ 
   //put Account.CID__C ...which we were having earlier 
}

https://stackoverflow.com/questions/33396999/onclick-javascript-button

1

Change your script to this:

if( '{!Account.CID__c}' == 'null' || '{!Account.CID__c}' == ''){
    window.open( '{! SUBSTITUTE($Setup.CustomSetting__c.Link__c,"[#CID#]",Account.AnotherField__C)}');
}
else {
    window.open( '{! SUBSTITUTE($Setup.CustomSetting__c.Link__c,"[#CID#]",Account.CID__c )}')
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.