You need to sign in to do that
Don't have an account?
Oliver Freeman 9
OnClick JS Button - IF Statement
Hi,
I have a requirement to create an OnClick JavaScript button which will essentially check whether the value of a field (Total Number of Contract Loans on Case) is greater than 1, if it is greater than 1, display an error message (alert), telling the user that there is more than one contract loan record raised against the case.
If the value is not greater than 1 (else), tick a checkbox field on the case (Replacement_Device_Issued__c).
I've tried the below script, but I'm getting a "Unexpected End of Script" error when trying to use it.
Any help greatly appreciated!
Thanks,
Oli
I have a requirement to create an OnClick JavaScript button which will essentially check whether the value of a field (Total Number of Contract Loans on Case) is greater than 1, if it is greater than 1, display an error message (alert), telling the user that there is more than one contract loan record raised against the case.
If the value is not greater than 1 (else), tick a checkbox field on the case (Replacement_Device_Issued__c).
I've tried the below script, but I'm getting a "Unexpected End of Script" error when trying to use it.
if('{Case.Total_Number_of_Contract_Loans_on_Case__c}' >1) { alert( "More than one contract loan." )) } else if('{Case.Total_Number_of_Contract_Loans_on_Case__c}' ==1) { var newRecords = []; var c = new sforce.SObject(Case); c.id ="{Case.Id}"; c.Replacement_Device_Issued__c = true; newRecords.push(c); result = sforce.connection.update(newRecords); window.location.reload(); }
Any help greatly appreciated!
Thanks,
Oli
Hope this Works!!
Try below code in your JS button it will update your checkbox field based on your condition.
Hope this will help you.
mark it solved if its works for you.
Thanks
karthik