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
sam_Adminsam_Admin 

Help with custom Button

I created Java script button but iam receving this error "A problem with the OnClick JavaScript for this button or link was encountered:
missing ; before statement". Here is my code

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

var Status = '{!ELA__c.Status__c}';

if(Status == "Active") {window.location = "/a02/e?retURL={!ELA__c.Id}&RecordType=01240000000M83B&00N40000002Hvox="ELA"&00N40000003BOiQ={!ELA__c.Name}&00N40000002HvWZ="IRB""}
else if(Status == "Inactive"){window.location = "/a02/e?retURL={!ELA__c.Id}&RecordType=01240000000M83B&00N40000002Hvox="BLA"&00N40000003BOiQ={!ELA__c.Name}&00N40000002HvWZ="CRB""}
 
Best Answer chosen by sam_Admin
KaranrajKaranraj
You have to use ; to end the statement in java script. Try the below code
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var Status = '{!ELA__c.Status__c}';

if(Status == "Active") {
window.location = "/a02/e?retURL={!ELA__c.Id}&RecordType=01240000000M83B&00N40000002Hvox=ELA&00N40000003BOiQ={!ELA__c.Name}&00N40000002HvWZ=IRB";
}
else if(Status == "Inactive"){
window.location = "/a02/e?retURL={!ELA__c.Id}&RecordType=01240000000M83B&00N40000002Hvox=BLA&00N40000003BOiQ={!ELA__c.Name}&00N40000002HvWZ=CRB";
}

 

All Answers

David ZhuDavid Zhu
missing semi colon for IF statement. 
sam_Adminsam_Admin
Still same error after semi colon
KaranrajKaranraj
You have to use ; to end the statement in java script. Try the below code
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var Status = '{!ELA__c.Status__c}';

if(Status == "Active") {
window.location = "/a02/e?retURL={!ELA__c.Id}&RecordType=01240000000M83B&00N40000002Hvox=ELA&00N40000003BOiQ={!ELA__c.Name}&00N40000002HvWZ=IRB";
}
else if(Status == "Inactive"){
window.location = "/a02/e?retURL={!ELA__c.Id}&RecordType=01240000000M83B&00N40000002Hvox=BLA&00N40000003BOiQ={!ELA__c.Name}&00N40000002HvWZ=CRB";
}

 
This was selected as the best answer