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
Sean O-ConnellSean O-Connell 

Java Script Button with Validation

I am looking to create a JavaScript Button with validation in to.  I want it to check to see if "State of Incorporation" (A picklist) is not null if null give an alert if not run the code.  Currently I am getting the below error and the code is also below thanks in advance for help


A problem with the OnClick JavaScript for this button or link was encountered:

Unexpected token {





{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")} 

if("{!Contact.State_of_Incorporation__c}" !==""{ 

var CRL='Email~VeraAuthorizedSigner@vera.com;FirstName~Vera;LastName~Authorized Signer;RoutingOrder~2;SignNow~0,Email~{!Contact.Email};Role~Signer 2;FirstName~{!Contact.FirstName};LastName~{!Contact.LastName};RoutingOrder~1;SignNow~0'; 
var DST ="AEF6F08B-B40F-4D11-A639-8B3B9604963D"; 





window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Contact.Id}&CRL="+CRL+"&DST="+DST; 



else{ 
Alert("must fill out State of Incorporation");
SalesFORCE_enFORCErSalesFORCE_enFORCEr
I don't see any closing bracket for else. Also, you don;t need double equals in not equals, it will be !=
Pramodh KumarPramodh Kumar
Try this.
 
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")} 

if("{!Contact.State_of_Incorporation__c}" !=""){ 

	var CRL='Email~VeraAuthorizedSigner@vera.com;FirstName~Vera;LastName~Authorized Signer;RoutingOrder~2;SignNow~0,Email~{!Contact.Email};Role~Signer 2;FirstName~{!Contact.FirstName};LastName~{!Contact.LastName};RoutingOrder~1;SignNow~0'; 
	var DST ="AEF6F08B-B40F-4D11-A639-8B3B9604963D"; 
}

 
Hans LissHans Liss
The "if" statement is missing a closing parenthesis:
if("{!Contact.State_of_Incorporation__c}" !==""{
That might be the reason for the "Unexpected token {" error.