You need to sign in to do that
Don't have an account?
Carlton Brumbelow
Convert Owner.Name to string - SOQL Queries in PHP
HI All,
I'm running the following query in PHP
When run in SOQLXplorer I get the results I want, but when run in PHP I can echo out Case.CaseNumber just fine, but Ower.Name gives me the following error
Here's my whole code, for context:
I'm running the following query in PHP
$query = "select Case.CaseNumber, Owner.Name from Case where Case.ID not in (select CaseComment.ParentID from CaseComment where CaseComment.CreatedDate = LAST_N_DAYS:5 OR CaseComment.LastModifiedDate = LAST_N_DAYS:7) AND Case.Status in ('Open', 'Waiting for Response', 'In Progress')";
When run in SOQLXplorer I get the results I want, but when run in PHP I can echo out Case.CaseNumber just fine, but Ower.Name gives me the following error
[Tue Feb 16 09:40:53.503974 2016] [:error] [pid 42960] [client 127.0.0.1:52997] PHP Catchable fatal error: Object of class stdClass could not be converted to string in /Library/Server/Web/Data/Sites/Default/sf-connect/CaseComment.php on line 32I get that Owner.Name is an object and not a string, but I've tried (string) to set the type when I echo
echo "<td>" . (string) $record->Owner.Name . "</td>";Are there good ways to do this conversion, or would it be better if I ran an additional query to grab this name?
Here's my whole code, for context:
<html> <head> <title>Support Engineer Case Comments</title> </head> <body> <?php define("USERNAME", "myusername"); define("PASSWORD", "mypassword"); define("SECURITY_TOKEN", "mytoken"); require_once ('/Library/Server/Web/Data/Sites/Default/sf-connect/soapclient/SforceEnterpriseClient.php'); $mySforceConnection = new SforceEnterpriseClient(); $mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml"); $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN); $query = "select Case.CaseNumber, Owner.Name from Case where Case.ID not in (select CaseComment.ParentID from CaseComment where CaseComment.CreatedDate = LAST_N_DAYS:5 OR CaseComment.LastModifiedDate = LAST_N_DAYS:7) AND Case.Status in ('Open', 'Waiting for Response', 'In Progress')"; $response = $mySforceConnection->query($query); echo "<h2>All Support Engineer cases without comments in the past 7 days"; echo "<table>"; foreach ($response->records as $record) { echo "<tr>"; echo "<td>" . $record->CaseNumber . "</td>"; echo "<td>" . $record->Owner.Name . "</td>"; echo "</tr>"; } echo "</table>"; ?> </body> </html>
Carlton Brumbelow
Nevermind, I figured it out with the object pointer. So instead of echoing Owner.Name I'm doing Owner->Name