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
rachvillrachvill 

fieldsToNull does not work

Hi,

fieldsToNull does not work in my code. I have a custom object, that has a custom field being set to null. I checked the definition and field that I'm trying to set to null is Nillable.

rec.fieldsToNull.push("Last_Name__c");
var saveResult = rec.save();
//alert(saveResult);
if (saveResult.className == "Fault") { //error
        alert("There was an error: " + saveResult.toString());
        return false;
}
return true;


Any help will be very much appreciated.


Rachel
rachvillrachvill
Hi,

Here's the resolution for my problem above.

rec.fieldsToNull.push("Last_Name__c");
rec.set("Last_Name__c","");

Just setting the field to "" does not work. Both lines of code are needed to make the field null. I don't know why. But it works.
DevAngelDevAngel
Hi rachvill,

Quick search of the forums reveals this post.

http://community.salesforce.com/sforce/board/message?board.id=ajax_toolkit&message.id=617

Message Edited by DevAngel on 11-15-2006 09:31 AM

rachvillrachvill
    Thanks for your help. I appreciate it.
SteveBowerSteveBower
fwiw, I use:

Code:
Sforce.Dynabean.prototype.setOrNull = function(propName, value) { 
 // If the value is null, add it to the fieldsToNull array.
 // otherwise, use the .set function to add the value to the record.
 if (value == "" || value == null ) {
  this.fieldsToNull.push(propName);
  this.set(propName,null);
 } else {
  this.set(propName,value);
 }
}