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
GerhardNewmanGerhardNewman 

Setting a field to NULL does not work.

I found lots of other posts on this topic and none of the solutions offered work.
 
I've tried fieldsToNULL by itself
I've tried fieldsToNull together with .set
I've tried just .set
 
With the code as it is below, it runs fine without error, but the field is not updated.
 
Someone please help!  BTW I am using Winter 08 in sandbox.
 
var myObj = new sforce.SObject("Lead");
myObj.Id = records[i].Id;
//myObj.set("Spotzer_Web_ID__c", null);
//myObj.fieldsToNull = [];
//myObj.fieldsToNull.push("Spotzer_Web_ID__c");
myObj.set("Spotzer_Web_ID__c","");
sforce.connection.update([myObj]);
 
CaptainObviousCaptainObvious
What you had *should* work:

myObj.set("Spotzer_Web_ID__c", null);

Unless it's a required field...
GerhardNewmanGerhardNewman
I've gone back to what you suggested, but still does not work.
 
The field is not a required field, however it is an External ID.  Not that I see why that should cause a problem....
CaptainObviousCaptainObvious
Are you able to manually clear the data in the field? (go to EDIT, clear the data from the field, and click SAVE).

If there's any kind of data validation going on, it could prevent the field from being set to null.
GerhardNewmanGerhardNewman

I just tried that before reading your post, and yes you are correct, all of my records are failing to update due to another problem.

I missed this due to the documentation on how to set to null being a bit vague (actually I could not find any at all) and getting a bit lost in my numerous tests.  Obvious problem captian obvious.

Thanks for your help.