I am trying to insert a null value into a field of type Date (in SalesForce) using a PHP Script.

Here is my logic.

$Date = '',
$createField['Date__c'] = $Date;

I tried the following, but none of them work.

$Date = '';
$Date = null;
$Date = NULL;
$Date = 'NULL';
$Date = 'null';
  • Null should work, facing any specific errors? – Raul Mar 10 '17 at 18:32

You need to use the fieldsToNull attribute, as noted in the update documentation.

$createField["fieldsToNull"] = array("Date__c");
  • How do we pass the value of $Date variable into this logic? Sorry. I am little bit lost here. – Java Mar 10 '17 at 19:50
  • @KingJava Assuming $Date is coming from somewhere else, you basically need to something like this if(empty($Date)) { $createField.fieldsToNull = array("Date__c"); } else { $createField["Date__c"] = $Date; } – sfdcfox Mar 10 '17 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.