Salesforce php工具包更新自定义字段


Salesforce php toolkit update custom field

我必须从我的Web应用程序创建记录到salesforce:

error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
ini_set('xmlrpc_errors', true);
define("USERNAME", "xxxxxxxxx");
define("PASSWORD", "xxxxxxxxx");
define("SECURITY_TOKEN", "xxxxxxxxxxxxxxxxxxxxxxxxxxx");
require_once ('soapclient/SforceEnterpriseClient.php');
$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
function createRecord(){
    global $mySforceConnection;
    $records = array();
    $records[0] = new stdclass();
    $records[0]->FirstName = 'Myriam';
    $records[0]->LastName = 'Makeba';
    $records[0]->Phone = '(510) 555-5555';
    $records[0]->BirthDate = '1957-01-25';
    $records[0]->contractType__c = "CDI";
    $response = $mySforceConnection->create($records, 'Contact');
    $ids = array();
    foreach ($response as $i => $result) {
        echo $records[$i]->FirstName . " " . $records[$i]->LastName . " "
                . $records[$i]->Phone . " created with id " . $result->id
                . "<br/>'n";
        array_push($ids, $result->id);
    }
}

你看到我想更新自定义字段"contractType__c",它给我带来了一个错误:

Fatal error: Uncaught SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: No such column 'TypeContrat__c' on entity 'Contact'.
If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. 
Please reference your WSDL or the describe call for the appropriate names.

如果我评论这一行,它会插入记录,我的目标是更新salesforce的自定义字段。抱歉我英语不好。

谢谢。

哎哟!上一条新闻我试图插入没有自定义字段的记录,我也得到了错误:

stdClass Object ( 
[errors] => Array ( 
[0] => stdClass Object ( 
[message] => ContactBeforeInsert: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.ContactBeforeInsert: line 83, column 1 [statusCode] => CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY ) ) 
[id] => [success] => ) 
stdClass Object ( 
[errors] => Array ( 
[0] => stdClass Object ( 
[message] => ContactBeforeInsert: execution of BeforeInsert caused by: System.NullPointerException: **Attempt to de-reference a null object Trigger.ContactBeforeInsert: line 83**, column 1 [statusCode] => CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY ) ) [id] => [success] => )

第一个错误:

根据您的描述,您收到的问题是"INVALID_FIELD:实体"Contact"上没有这样的列"TypeContrat_c"。因此,请在salesforce中检查该字段的api名称。我认为您在联系人的自定义字段的api名称中缺少一些内容。

第二个错误:

在你的salesforce组织中,有一个联系人的触发器"ContactBeforeInsert",它会得到一个空指针异常。(意味着他们正在检索某个值,而该值为空)。所以请检查触发器。按照步骤查看联系人触发器的goto设置->自定义->联系人->触发器列表。