You need to sign in to do that
Don't have an account?
WesNolte__c
Dynamically fetching parent fields in a dynamic SOQL query
Hello,
I've run into some trouble trying to fetch related object fields from a dynamic query using SObjects e.g.
String qs = 'SELECT account.name FROM Contact LIMIT 1'; SObject s = database.query(qs); String name = s.get('account.name'); // OR SObject account = s.get('account');
So neither of the bottom two lines execute and I really need to fetch that information out and into a generic SObject. Anyone have a solution?
Wes
Hi Weznolte,
With Dynamic Apex you'll need to pull out the parent sobject first using the getSObject method and then do a second call to get the name.
All Answers
Hi Weznolte,
With Dynamic Apex you'll need to pull out the parent sobject first using the getSObject method and then do a second call to get the name.
Cheers.