You need to sign in to do that
Don't have an account?
K_T
How to get a child sobject's parent's field?
I am trying to retrieve a child sobject's parent's field, but I'm getting an invalid field error. This is the code snippet:
The account Id would be the Id of an account with contacts, of course.
Is this a known limitation of Salesforce?
The account Id would be the Id of an account with contacts, of course.
List<Sobject> sobjectList = [SELECT Id, (SELECT Owner.Name, ownerId FROM Contacts) FROM Account where Id = '001E000000nG22yIAC' ]; List<Sobject> contList = sobjectList.get(0).getSobjects('contacts'); System.debug(loggingLevel.ERROR, 'cont list: ' + contList); for (Sobject cont : contList) { String name = (String)cont.get('Owner.Name'); System.debug(loggingLevel.ERROR, ' name: ' + name); }
Is this a known limitation of Salesforce?
All Answers
Thanks!