I have the following object (hed__Course_Enrollment__c), with a relation to the Contact object:
For a given hed__Course_Enrollment__c Id, I want to show the first and last name of the contacts.
If I make the next query, I get the IDs of the contacts:
$query = "Select Id,hed__Contact__c FROM hed__Course_Enrollment__c WHERE hed__Course_Offering__c='a042o000013Z2tiAAC'";
How can I get the contact's first and last name on the same call? I've tried some querys but I get errors ...
Example 1:
$query = "Select h.Id,h.hed__Contact__c, c.FirstName, c.LastName FROM hed__Course_Enrollment__c, Contact c h WHERE h.hed__Course_Offering__c='a042o000013Z2tiAAC'";
Fatal error: Uncaught SoapFault exception: [sf:MALFORMED_QUERY] MALFORMED_QUERY: hed__Course_Enrollment__c, Contact c h WHERE h.hed__Course_Offering__c='a042o000013Z2tiAAC' ^ ERROR at Row:1:Column:96 unexpected token: 'c' in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\EUTA\portal\e\soapclient\SforceBaseClient.php:789 Stack trace: #0 C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\EUTA\portal\e\soapclient\SforceBaseClient.php(789): SoapClient->__call('query', Array) #1 C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\EUTA\portal\e\test.php(122): SforceBaseClient->query('Select h.Id,h.h...') #2 {main} thrown in ...
Example 2:
$query = "Select Id,hed__Contact__c, (SELECT FirstName, LastName FROM Contact) FROM hed__Course_Enrollment__c WHERE hed__Course_Offering__c='a042o000013Z2tiAAC'";
Fatal error: Uncaught SoapFault exception: [sf:INVALID_TYPE] INVALID_TYPE: (SELECT FirstName, LastName FROM Contact) FROM hed__Course_Enrollment__c ^ ERROR at Row:1:Column:61 Didn't understand relationship 'Contact' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the 'r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\EUTA\portal\e\soapclient\SforceBaseClient.php:789 Stack trace: #0 C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\EUTA\portal\e\soapclient\SforceBaseClient.php(789): SoapClient->__call('query', Array) #1 C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\EUTA\portal\e\test.php(122): SforceBaseClient->query('Select Id,hed...') #2 {main} thrown in ...
I'm doing something wrong in relationships ... but I don't know what it is.
Can anybody help me?
Thanks!!