2014-01-09 17 views
0

嘗試使用SOAP連接器向Salesforce發送一些數據時出現follwing錯誤。對於xsd類型無效的值:日期

'0000-00-00' is not a valid value for the type xsd:date' 

這發生在日期輸入無效或空時。我可以發送一些正確的日期,如'2000-10-10'以避免錯誤。但它不正確。所以我需要使該字段爲NULL。即使我傳遞NULL也會引發相同的錯誤。我也試過fieldsToNull。但它沒有奏效。

我正在使用Salesforce Enterprise WSDL。

$records = array(); 
$records[0] = new \stdclass(); 

$records[0]->Date_of_Birth__c = (!empty($date_of_birth)) ? $date_of_birth : '0000-00-00'; 
$this->client->create($records, 'Profile__c'); 

如何解決這個問題?

回答

1

正如你所做的創建,你可以跳過設置該字段,如果你沒有它的價值,例如,

$records = array(); 
$records[0] = new \stdclass(); 
if (!empty($date_of_birth)) 
    $records[0]->Date_of_Birth__c = $date_of_birth; 

$this->client->create($records, 'Profile__c');