php salesforce新手无效_字段:没有此类列';字段';关于实体';联系方式';
我有一个艰难的时间,花了大约4个小时试图调试这个。我是PHP新手,但没想到这会如此困难 这是代码,我正在尝试更新联系人表。我尝试了升级和更新,但似乎没有任何效果 这是代码的“更新”版本php salesforce新手无效_字段:没有此类列';字段';关于实体';联系方式';,php,salesforce,Php,Salesforce,我有一个艰难的时间,花了大约4个小时试图调试这个。我是PHP新手,但没想到这会如此困难 这是代码,我正在尝试更新联系人表。我尝试了升级和更新,但似乎没有任何效果 这是代码的“更新”版本 $id = '003A000000XRVFxIAP'; $updateFields = array ( 'Id' => $id, 'MailingCity' => 'New York', 'MailingState' => 'NY'
$id = '003A000000XRVFxIAP';
$updateFields = array (
'Id' => $id,
'MailingCity' => 'New York',
'MailingState' => 'NY'
);
$sObject1 = new SObject();
//$sObject1->fields = $updateFields;
//$sObject1->MailingCity= 'New York';
$sObject1->type = 'Contact';
try{
$updateResponse = $client->update(array($sObject1),'Contact');
$myID = $updateResponse->id;
}
Strict Standards: Creating default object from empty value in C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceEnterpriseClient.php on line 89 INVALID_FIELD: No such column 'fields' 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. Error Info SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: No such column 'fields' 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. in C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceBaseClient.php:508 Stack trace: #0 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceBaseClient.php(508): SoapClient->__call('update', Array) #1 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceBaseClient.php(508): SoapClient->update(Object(stdClass))
#2 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceEnterpriseClient.php(90): SforceBaseClient->_update(Object(stdClass))
#3 C:\xampp\htdocs\Proj1\createAccount.php(95): SforceEnterpriseClient->update(Array, 'Contact') #4 {main}
查看您的跟踪,您似乎正在使用企业客户端,我可以假设企业WSDL。这是强类型的,您应该使用特定于您的Salesforce组织的WSDL。如果您不使用从您的组织下载的WSDL,它将不会在其中定义正确的对象和字段 我建议使用合作伙伴客户机和合作伙伴WSDL。这是一种松散的类型,而且更加灵活。如果您不熟悉PHP或Web服务,使用它会更容易 以下内容应该会做您的更新
$sObject1 = new stdClass();
$sObject1->type = 'Contact';
$sObject1->Id = $id;
$sObject1->fields['MailingCity'] = 'New York';
$sObject1->fields['MailingState'] = 'NY';
try
{
$updateResponse = $client->update( array( $sObject1 ) );
}
catch( Exception $exception )
{
// Do something
}
请注意,Id是$sObject的一个属性,而不是字段数组中的一个值。此外,无需在更新调用中指定“联系人”,因为它是在$sObject的type属性中设置的。使用企业WSDL时,不要创建
新sObject
,只需创建新stdClass
。请参阅中的示例;SObjects仅用于合作伙伴WSDL。我在使用企业客户端更新时遇到了相同的问题。我在更新帐户对象上的自定义字段时遇到了相同的问题
我对SObject的问题是,它试图在更新期间更新名为“fields”的参数。由于企业WSDL不包括该字段,我使用unset()
从SObject中删除“fields”属性
我很欣赏这是一个有点黑客的解决方案,但它可能会对其他遇到这个问题的人有用
$sUpdateObject = new SObject();
$sUpdateObject->id = $record->Id;
$sUpdateObject->MyCustomField__c = 0;
unset($sUpdateObject->fields);
$updateResponse = $mySforceConnection->update(array($sUpdateObject), 'Account');
print_r($upsertResponse);