Jump to content

Recommended Posts

How would I get Id from this array:

QueryResult Object ( [queryLocator] => [done] => 1 [records] => Array ( [0] => SObject Object ( [type] => [fields] => [id] => 00QE0000001nvBTMAY ) [1] => SObject Object ( [type] => [fields] => [id] => 00QE0000001nvB5MAI ) ) => 2 )

 

My code not working:

$client = new SforceEnterpriseClient();
$client->createConnection($wsdl);
$client->login($user, $pass . $token);
$query = "SELECT Id from Lead WHERE Company = 'Jamoke, Inc.'";  

$response = $client->query(($query));  
print_r($response);
$eLEADID = $response->Id;
echo "Lead Id:" . $eLEADID;
  $leadConvert = new stdClass;
  $leadConvert->convertedStatus='Closed - Converted';
  $leadConvert->doNotCreateOpportunity='false';
  $leadConvert->leadId=$eLEADID;
  $leadConvert->overwriteLeadSource='true';
  $leadConvert->sendNotificationEmail='true';

  $leadConvertArray = array($leadConvert);
  $leadConvertResponse = $client->convertLead($leadConvertArray);

 

$eLEADID comes up empty....

Im working on Saleforce integration and want to convert a lead to an Account.

Link to comment
https://forums.phpfreaks.com/topic/239352-get-data-from-an-array/
Share on other sites

Just did a google on the SforceEnterpriseClient class and came across this documentation. As the documentation showws you need to loop over the results ($responce) and convert the records into SObjects.

$response = $client->query($query); 

foreach($response as $record)
{
     $sObject = new SObject($record); // covert current record into SObject
     echo $sObject->Id; // get the id of the currect record
}

I tried this earlier, still cant get it. I know its something simple...

foreach($response as $record){

$sObject = new SObject($record);

echo $sObject->Id;   

print_r($sObject);

}

Returns:

SObject Object ( [type] => [fields] => ) SObject Object ( [type] => [fields] => ) SObject Object ( [type] => [fields] => [1] => SObject Object ( [type] => [fields] => [id] => 00QE0000001nvB5MAI ) ) SObject Object ( [type] => [fields] => )

 

and no Id's are output.  :shrug:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.