function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SrBlancoSrBlanco 

PHP: Unable to update custom fields with Enterprise 1.1

ARGH!!

So using the example from the wiki as my guide:

Code:
http://wiki.apexdevnet.com/index.php/Members:PHP_Toolkit_1.1_Update_Sample_%28Enterprise%29

 
I am able to update standard fileds in cases wihtout issue.  I cannot, however get custom fields to update.

When I do a getLastRequest I cannot even see my custom fields referenced in the SOAP call.  Someone please point me in the right direction on updating custom fields through the Enterprise 1.1 api.

My code below:

Code:
require_once ('soapclient/SforceEnterpriseClient.php');
require_once ('soapclient/SforceHeaderOptions.php');

try {
  $sfc_connection = new SforceEnterpriseClient();
  $mySoapClient = $sfc_connection->createConnection("enterprise.wsdl.xml");
  $sfc_login = $sfc_connection->login("SFC_USR", "SFC_PWD");

  $userResult = $sfc_login->userInfo;
  echo $userResult->userFullName . ', your session id is ' . $sfc_login->sessionId;
    
  $sObject1             = new stdClass;
  $sObject1->Subject    = 'Test issue 1';
  $sObject1->zzTest__c  = 'text';
  $sObject1->Id         = '50020000000hl5kAAA';
 
  print_r($sObject1);
 
  $response = $sfc_connection->update(array ($sObject1), "Case");

  print_r($response);
  print_r($sfc_connection->getLastRequest());
  print_r($sfc_connection->getLastResponse());
} catch (Exception $e) {
  echo $e->faultstring;
}

 

cavnebcavneb
It may not be the best solution, but you can try to create an array of the parameters instead of creating a stdClass.

For example:

Code:
  $vars = array (
    'Subject'    => 'Test issue 1',
    'zzTest__c'  => 'text',
    'Id'         => '50020000000hl5kAAA'
  )
 
  $response = $sfc_connection->update($vars, "Case");

 

SrBlancoSrBlanco
Thanks for the suggestion but it was a no-go.  I had to execute the update like this to get it to work:
Code:
$response = $sfc_connection->update(array($vars), "Case");

 
Unfortunitely it still wouldnt update the custom field.  The standard field (Subject) updated just fine though which is quite perpelexing. 
dkellydkelly

Hi, I had a very similar issue with the Ajax toolkit. Not sure if the requirements are the same or not.

With the Ajax toolkit, I could only update the custom field if it was placed on a "Page Layout".

I also ran into issues with non-admin users updating it if it was marked as read only.

Hope this info helps

Good Luck

Don

SrBlancoSrBlanco
Hi Don,

Thanks for posting.  Unfortunitely none of your suggestions are the answer.  The custom field I am trying to update exists on a page layout, is not read-only, and I am using my admin creds in the script to try and update it. 

-Michael
Tran ManTran Man
Just a thought, did you redownload the enterprise.wsdl after you added the custom field?


SrBlancoSrBlanco
Thanks Nick,

You are once again my hero.  Updating the enterprise.wsdl did the trick.

Clearly I am missing some fundamental concepts.  Can anyone point me to some good "beginner" documentation on accessing sfdc through the API?


Thanks,

Michael
SuperfellSuperfell
API Docs include a getting started section.
SrBlancoSrBlanco
Thanks Simon.