+ Start a Discussion

Not getting an error when updating non-nillable to null...

Hi, I've built a page that updates the lead object & when I try to update the Company or LastName fields with null, it doesn't throw an error in the saveResult... It doesn't update to null & the data stays the same, but it's not throwing an error.  Just wondering if this is a known issue and what I should do, otherwise, if it is.


Here's a code snippet if you need it:

function saveLead() {
 var updateArray = new Array();
 var _value = leadSql[0];

 var updateVal = sforceClient.Update(updateArray);
 if(updateVal[0].success == true) {
  alert("Your changes have been saved");
 } else {
  alert("There was a problem with the data you entered.  Please edit and try again.");


use the fieldsToNull array.
I'm not sure what you mean by that...

I'm not actually trying to set it to null.  All I want to do is be able to catch errors when fields don't update and if someone tries to set a non-nillable field to null, I want to catch that error and let them know.  If I try to set a non-nillable filed to null right now, the saveResult update comes back as successful, but the data doesn't change.  I guess I could just validate before submission & skip it altogether.
Because you can't set a field to null by setting it to null, you have to explicitly use the fieldsToNull array to set a field value to null. If you do this, then the save will return a failure for that row if you try and set a non-nullable field to null. See the docs on fieldsToNull.
Ron HessRon Hess
snippet for your review, note the variable bean is a Dynabean for a custom object with a field Description__c

var elementid = "Description"+lkid;
var desc = document.forms['editPage'].elements[elementid].value;
if ( desc != null ) { 
} else { 


Awesome, thanks guys.