function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
evgenykaevgenyka 

Ho to create a null date

Hello
How can i insert null date in custom object
i have tried: NULL ,' ', " ", 00:00:00
and always getting this error

Fatal error: Uncaught SoapFault exception: [soapenv:Client] 'NULL' is not a valid value for the type xsd:date in /oracle_general/SF/sforce-php/soapclient/SforceBaseClient.php:585
Stack trace:
#0 [internal function]: SoapClient->__call('upsert', Array)
#1 /oracle_general/SF/sforce-php/soapclient/SforceBaseClient.php(585): SoapClient->upsert(Object(stdClass))
#2 /oracle_general/SF/line_load.php(144): SforceBaseClient->upsert('LINE_ID__C', Array)
#3 {main}
  thrown in /oracle_general/SF/sforce-php/soapclient/SforceBaseClient.php on line 585




Park Walker (TAGL)Park Walker (TAGL)
You need to use 'fieldsToNull' by adding an array to your fields list, something like:

$fields->fieldsToNull = array('myDateField');

evgenykaevgenyka
Still not working for me
Is this also working on create and not for update?

Code:
   
   $createFields=array(
          'Name' => ociresult($stmt, "NAME"),
             'LINE_ID__C'=> ociresult($stmt, "LINE_ID__C"),
          'ORACLE_ORDER_ID__C'=> ociresult($stmt, "ORACLE_ORDER_ID__C"),
         'ORDERED_ITEM__C'=>ociresult($stmt, "ORACLE_ORDER_ID__C"),
          'REF_ONLY_PN__C' => ociresult($stmt, "REF_ONLY_PN__C"),
    'PRODUCT_FAMILY__C' => ociresult($stmt, "PRODUCT_FAMILY__C"),
    'PRODUCT_TYPE__C' => ociresult($stmt, "PRODUCT_TYPE__C"),
    'S__C' => ociresult($stmt, "S__C"),
    'LINE_NUMBER__C' => ociresult($stmt, "LINE_NUMBER__C"),
    'CUST_PO_NUMBER__C' => ociresult($stmt, "CUST_PO_NUMBER__C"),
    'QTY__C' => ociresult($stmt, "QTY__C"),        
    'UNIT_SELLING_PRICE__C' => ociresult($stmt, "UNIT_SELLING_PRICE__C"),
    'SELLING_AMOUNT__C' => ociresult($stmt, "SELLING_AMOUNT__C"),
    'BOOKED_DATE__C' => ociresult($stmt, "BOOKED_DATE__C"),
    'CRD__C' => ociresult($stmt, "CRD__C"),
    'FSD__C' => ociresult($stmt, "FSD__C"),
    'CSD__C' => ociresult($stmt, "CSD__C"),
    'BBBSDT__C' => ociresult($stmt, "BBBSDT__C"),
    'ACTUAL_SHIPMENT_DATE__C' => $ship_date,
    'HOLDS_QTY__C' => ociresult($stmt, "HOLDS_QTY__C"),
    'CUST_PO_NUMBER__C' => ociresult($stmt, "CUST_PO_NUMBER__C"),
    'FREIGHT_CARRIER_CODE__C'=>ociresult($stmt, "FREIGHT_CARRIER_CODE__C"),
                 'BBBSDT_QUARTER_YEAR__C'=>ociresult($stmt, "BBBSDT_QUARTER_YEAR"),
         'WAYBILL__C'=>ociresult($stmt, "WAYBILL__C"),
    'ORDER__C'=>$ORDER_ID
     
       );
   if (ociresult($stmt, "ACTUAL_SHIPMENT_DATE__C")==''){
    $createFields->fieldsToNull = array('ACTUAL_SHIPMENT_DATE__C'); 
   }
   if (ociresult($stmt, "BOOKED_DATE__C")==''){
    $createFields->fieldsToNull = array('BOOKED_DATE__C'); 
   }
   if (ociresult($stmt, "CRD__C")==''){
    $createFields->fieldsToNull = array('CRD__C'); 
   }
   if (ociresult($stmt, "FSD__C")==''){
    $createFields->fieldsToNull = array('FSD__C'); 
   }

   if (ociresult($stmt, "CSD__C")==''){
    $createFields->fieldsToNull = array('CSD__C'); 
   }

   if (ociresult($stmt, "BBBSDT__C")==''){
    $createFields->fieldsToNull = array('BBBSDT__C'); 
   }


 

Park Walker (TAGL)Park Walker (TAGL)
Try changing
$createFields->fieldsToNull = array('whatever');
to
$createFields->fieldsToNull = array();
$createFields->fieldsToNull[] ='field1';
$createFields->fieldsToNull[] ='field2; and so on
or
$createFields->fieldsToNull = array();
array_push($createFields->fieldsToNull,'field1');
array_push($createFields->fieldsToNull,'field2'); and so on

Your current statement replaces the value of fieldsToNull on each statement.

I would also suggest using the correct case for your field names, according to your WSDL. They will not be all upper case and will end in '__c'.

fieldsToNull is not necessary (or valid) on create; just do not pass the values that are to be left null.