+ Start a Discussion
AmphitriteAmphitrite 

Javascript Onclick button - 'Null is not defined'

I have 4 text fields that I need to set to null. But am getting an error 'Null is not definied' when trying to use the button. Any feedback as to syntax for this?

 

 

 

Here is the relevant piece of my javascript Onclick button code:

 

var caseUpdate = new sforce.SObject("Case");

 

caseUpdate.Id = caseObj.Id;
caseUpdate.InEditUserId__c = Null;
caseUpdate.InEditUser__c =Null;
caseUpdate.InEditTime__c =Null;
caseUpdate.InEditViewURL__c=Null;


updateRecords.push(caseUpdate);

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Dhaval PanchalDhaval Panchal

Use "null" instead of "Null".

 

var caseUpdate = new sforce.SObject("Case");

 

caseUpdate.Id = caseObj.Id;
caseUpdate.InEditUserId__c = null;
caseUpdate.InEditUser__c = null;
caseUpdate.InEditTime__c = null;
caseUpdate.InEditViewURL__c= null;


updateRecords.push(caseUpdate);

All Answers

RovRov
Trying replacing the Null with single quotes ''
Dhaval PanchalDhaval Panchal

Use "null" instead of "Null".

 

var caseUpdate = new sforce.SObject("Case");

 

caseUpdate.Id = caseObj.Id;
caseUpdate.InEditUserId__c = null;
caseUpdate.InEditUser__c = null;
caseUpdate.InEditTime__c = null;
caseUpdate.InEditViewURL__c= null;


updateRecords.push(caseUpdate);
This was selected as the best answer
John BrothertonJohn Brotherton
Try caseUpdate.InEditUserId__c == null;

That worked for me on a JavaScript button. Hope that helps!