3

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';
1
  • Null should work, facing any specific errors?
    – Raul
    Mar 10, 2017 at 18:32

1 Answer 1

4

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

$createField["fieldsToNull"] = array("Date__c");
2
  • How do we pass the value of $Date variable into this logic? Sorry. I am little bit lost here.
    – Java
    Mar 10, 2017 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, 2017 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .