Jump to content

Get Data from an Array


savagenoob

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:

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.