You need to sign in to do that
Don't have an account?

How to set Date Field to Null?
![]() |
Hi
I am using AJAX ToolKit version 3.
I want to know how to set a date field in a DynaBean to null and save it(update)?
var tmpDOB=new Date("00/00/0000");
tmpDOB=null;
MyBean.set("DateOfBirth__c",tmpDOB);
saveResultCreate = sforceClient.Update(MyBean);
The above code runs with no error, but the date field is not set to null and old value of the field is retained.
Thanks
Jay
|
use the fieldsToNull array on the dynabean
example from an unrelated scontrol, where bean is a dynabean and i am clearing out a number field, same should work for date fields
Code:
WenBean.set("Id",document.all("hdnId"+RowId).value);
WenBean.set("Name",document.all("txtName" + RowId).value);
WenBean.set("Address__c",document.all("txtAddress" + RowId).value);
WenBean.set("Phone__c",document.all("Phone" + RowId).value);
if(document.all("txtDOB" + RowId).value!="")
{
var tmpDOB=new Date(document.all("txtDOB" + RowId).value);
WenBean.set("DateOfBirth__c",tmpDOB);
}
else
{
WenBean.fieldsToNull.push("DateOfBirth__c");
}
saveResultCreate = sforceClient.Update(WenBean);