Salesforce php 工具包更新自定义字段
Salesforce php toolkit update custom field
我必须创建从我的 webapp 到 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",并且它正在获取空指针异常。 (意味着他们正在检索一些值并且该值为空)。所以请检查那个触发器。按照步骤查看联系人触发器的列表,转到设置-> 自定义-> 联系人-> 触发器。
我必须创建从我的 webapp 到 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",并且它正在获取空指针异常。 (意味着他们正在检索一些值并且该值为空)。所以请检查那个触发器。按照步骤查看联系人触发器的列表,转到设置-> 自定义-> 联系人-> 触发器。