+ Start a Discussion
Shawn Kaiser 7Shawn Kaiser 7 

button logic not working

I have a button that I have incorporated some validation rule into for fields that need to be filled in. I am having issue with the fields that are picklists. Below is the code I have but the error I am getting is:<span class="errorStyle">Error: Syntax error. Missing '}'</span>

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

var isFilled = {!NOT(ISBLANK( Contact.Start_Date__c  ))};
var isFilled = {!NOT(ISBLANK( Contact.Escort_Day_1__c ))};
var isFilled = {!TEXT( Contact.Preferred_Computer__c  <>  '' ))};
var isFilled = {!TEXT( Contact.Office_Location__c  <>  ''  ))};
var isFilled = {!TEXT( Contact.Riskonnect_Department__c  <>  ''  ))};
var isFilled = {!TEXT( Contact.Accounting_Department__c  <>  '' ))};

if( isFilled){var contactRec = new sforce.SObject( "Contact" );
var records = sforce.connection.query("SELECT Id, Onboarding_Process_Builder_Trigger__c FROM Contact Where id = '{!Contact.Id}'");
var contactRec = records.getArray('records')[0];  



    contactRec.Onboarding_Process_Builder_Trigger__c = {!Contact.Onboarding_Process_Builder_Trigger__c} + 1; 

 sforce.connection.update([contactRec]); 
    window.location.reload();}

else {alert( "Employment Section is required." );}
María Angelica BuffaMaría Angelica Buffa
Hi Shawn, 

You have an extra parentheses in these lines: 

var isFilled = {!TEXT( Contact.Preferred_Computer__c  <>  '' ))};

I tried to remove that extra parentheses and it worked for me. 

Thanks!
Shruti SShruti S
Please try the below code - 
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")} 

var isFilled = {!NOT(ISBLANK(Contact.Start_Date__c ))}                      &&
               {!NOT(ISBLANK(Contact.Escort_Day_1__c))}                     &&
               {!NOT(ISBLANK(TEXT(Contact.Preferred_Computer__c)))}         &&
               {!NOT(ISBLANK(TEXT(Contact.Office_Location__c)))}            &&
               {!NOT(ISBLANK(TEXT(Contact.Riskonnect_Department__c)))}      &&
               {!NOT(ISBLANK(TEXT(Contact.Accounting_Department__c)))};

if( isFilled ) {
    var contactRec = new sforce.SObject( "Contact" );

    contactRec.Id = "{!Contact.Id}"

    contactRec.Onboarding_Process_Builder_Trigger__c = {!Contact.Onboarding_Process_Builder_Trigger__c} + 1; 

    var result = sforce.connection.update( [ contactRec ] );

    if( result[0].getBoolean( "success" ) ) {
        location.reload();
    }
    else {
        alert( result );
    }
}
else {
    alert( "Employment Section is required." );
}
Shawn Kaiser 7Shawn Kaiser 7
Thank you so much! That was it! Appreciate the help! Shawn Kaiser Manager CRM Administration Riskonnect, Inc. 1701 Barrett Lakes Blvd., Suite 500 Kennesaw, GA 30144 +1-770-790-4700 Main +1-585-784-0080 Mobile shawn.kaiser@riskonnect.com www.riskonnect.com