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

Set Date Field to Null using AJAX Toolkit
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(WenBean);
The above code runs with no error, but the date field is not set to null.
Thanks
Jay
Hi
Please ignore the typo in the question above.
saveResultCreate = sforceClient.Update(MyBean);
Thanks
Jay
Use the fieldsToNull array in the object instead of trying to .set(field,null) which doesn't work.
Search the boards for sample code.
Hi,
Thanks, it worked.
The following is the working code.
=============================
var WenBean = new Sforce.Dynabean("Wen_s_test__c");
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);