2011-03-13 3 views
1

힘든 시간을 보내고 4 시간 정도를 디버깅하려했습니다. 나는 PHP를 처음 사용하지만, 그렇게 열심히하기를 기대하지는 않았다.php salesforce 초심자 INVALID_FIELD : 엔티티 '연락처'에 해당 열 'fields'이 없습니다.

이것은 코드입니다. 연락처 테이블을 업데이트하려고합니다. 내가 upsert을 시도하고 nothign를 업데이트하면이 코드의 업데이트 "버전입니다

을 작동하는 것 같다.

$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} 

답변

1

엔터프라이즈 클라이언트를 사용하는 것으로 나타 나는 기업 WSDL을 가정 할 수 있습니다 추적에서 찾고있다.이 Salesforce org에만 해당하는 WSDL을 사용해야합니다. 조직에서 다운로드 한 WSDL을 사용하지 않는 경우 올바른 개체 및 필드가 정의되지 않습니다.

파트너 사용을 권장합니다. 클라이언트 및 파트너 WSDL을 제공합니다. 이는 느슨하게 입력되고 훨씬 유연합니다. 특히 PHP 나 웹 서비스에 익숙하지 않은 경우. 다음은 당신의 갱신을해야

... 이드 달러 (A $) sObject의 재산이 아닌 필드 배열의 값입니다

$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 
} 

참고. $ sObject의 type 속성에서 설정 했으므로 업데이트 호출에 'Contact'를 지정할 필요가 없습니다.

1

엔터프라이즈 WSDL을 사용하는 경우 new SObject을 만들지 말고 new stdClass을 만듭니다. PHP Getting Started Guide의 예를 참조하십시오. SObject는 파트너 WSDL에서만 사용됩니다.

+0

+1 이것은 WSDL 변경보다 나은 해결책입니다. – hudolejev

0

엔터프라이즈 클라이언트를 사용하는 동안 동일한 문제가 업데이트되었습니다. Account 개체의 사용자 지정 필드를 업데이트하는 동안 동일한 문제가 발생했습니다.

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); 
관련 문제