You need to sign in to do that
Don't have an account?
AK123
Custom Java button - If statement
Hello, I am trying to write code for a custom button using Java, please see below:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var caseObj = new sforce.SObject("Lead"); caseObj.Id = '{!Lead.Id}'; caseObj.Rating = '2'; caseObj.Customer_Interest_Level__c= "Interested to learn more about FX"; caseObj.ATL__c= '{!User.Id}'; if (caseObj.ATL_Pass__c==null) { caseObj.ATL_Pass__c='{!User.Id}'} var result = sforce.connection.update([caseObj]); if (result[0].success=='false') { alert(result[0].errors.message); } else { location.reload(true); }
Basically I am trying: if ATL_pass__c = null, then update this field to the current user ID. If not, leave untouched. The conditional portion of this (in red above) does not seem to be working. It is changing the value of ATL_pass__c regardless if it is null or not. Please advise.
Thanks!
if (caseObj.ATL_Pass__c==null) {
caseObj.ATL_Pass__c='{!User.Id}'}
try this
if (caseObj.ATL_Pass__c==null) {
caseObj.ATL_Pass__c="{!User.Id}"}
Thanks Dhaval, however it did not work. The IF statement is still not working correctly, please advise.