Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Perl, PHP, Python & Ruby Development
- :
- Re: $record->fields->Firstname doesn't give me th...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
$record->f ields->Fir stname doesn't give me the Firstname of Contact field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-17-2012 08:11 AM
Hello, I'm trying the simple query from the docu.
using the actual version of php toolkit.
only to try out Enterprise wsdl (works fine) and Partner wsdl on the other side.
partner wsdl doesn't give me the expected results.
I only see the id of the contact, and the other fields are combined in any- field.
I want to give out the Firstname, Lastname and so on.
here is the code:
<?php
session_start();
require_once ('soapclient/SforcePartnerClient.php');
require_once ('soapclient/SforceHeaderOptions.php');
//require_once ('soapclient/SforceEnterpriseClient.php');
define ("USERNAME", "myuser@blabla.de");
define("PASSWORD", "mypw");
define("SECURITY_TOKEN", "mytoken");
try {
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection("soapclient/
if (isset($_SESSION['partnerSessionId'])) {
$location = $_SESSION['partnerLocation'];
$sessionId = $_SESSION['partnerSessionId'];
$mySforceConnection->setEndpoint($location);
$mySforceConnection->setSessionHeader($sessionId);
echo "Used session ID for partner<br/><br/>\n";
} else {
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$_SESSION['partnerLocation'] = $mySforceConnection->getLocation();
$_SESSION['partnerSessionId'] = $mySforceConnection->getSessionId();
echo "Logged in with partner<br/><br/>\n";
}
$query = "SELECT Id, FirstName, LastName, Phone from Contact";
$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);
foreach ($queryResult->records as $record) {
print_r($record);
echo $record->Id . ": " . $record->fields->FirstName . " "
. $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
}
} catch (Exception $e) {
echo "Exception ".$e->faultstring."<br/><br/>\n";
echo "Last Request:<br/><br/>\n";
echo $mySforceConnection->getLastRequestHeaders();
echo "<br/><br/>\n";
echo $mySforceConnection->getLastRequest();
echo "<br/><br/>\n";
echo "Last Response:<br/><br/>\n";
echo $mySforceConnection->getLastResponseHeaders();
echo "<br/><br/>\n";
echo $mySforceConnection->getLastResponse();
}
?>
the doc says, that it works with ...
$record->fields->FirstName
but this works not in my case.
may be a simple beginner mistake - can you help me?
thanks a lot,
Adi
Re: $record->f ields->Fir stname doesn't give me the Firstname of Contact field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-18-2012 09:39 AM
This looks to be correct. What does the print_r($record) statement produce?
Re: $record->f ields->Fir stname doesn't give me the Firstname of Contact field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-19-2012 12:44 AM
hello redsummit,
print_r($record) gives me for example:
stdClass Object ( [type] => Contact [Id] => Array ( [0] => 003d000000P84mVAAR [1] => 003d000000P84mVAAR ) [any] => KonradXxx0171-2323052 ) Array:
stdClass Object ( [type] => Contact [Id] => Array ( [0] => 003d000000P84kHAAR [1] => 003d000000P84kHAAR ) [any] => SonjaSyyy08102-8749027 ) Array:
stdClass Object ( [type] => Contact [Id] => Array ( [0] => 003d000000U6yGOAAZ [1] => 003d000000U6yGOAAZ ) [any] => AdiSchlachtertest Array:
seems likecontakt- id is separated and lastname, firstname,phone is collected in [any]...
I'm sure it's a very beginner problem, but i don't understand how it works.
the developer sample for partner wsdl is
echo $record->Id . ": " . $record->fields->FirstName . " "
. $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
and produces me only "array:"
thanks for your answer, I'm sure you can help me becoming better ;-)
Adi
Re: $record->f ields->Fir stname doesn't give me the Firstname of Contact field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-19-2012 01:14 AM
hello redsummit,
I think it was basic programmer problem ;-)
$queryResult = new QueryResult($response);
foreach ($queryResult as $record) {
print_r($record);
echo $record->Id . ": " . $record->fields->FirstName . " "
. $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
}
produces the expected output.
foreach ($queryResult->records as $record) was wrong !!!!!
sorry for that stupid question !!!
Adi

