Hot answers tagged


Yes, you are allowed to do so, assuming you use Database.AllowsCallouts and you have no pending DML statements (e.g. you have not used insert/upsert/update/merge/delete/undelete/etc).


Dynamic SOQL and a little bit of DescribeSObjectResult magic should work for you. This is simple anon apex and I advise you to break it out into its own method that could accept many queryObject and many type of relationshipAPI. String relationshipAPI = 'Parent__r.GrandParent__r.'; String queryObject = 'Child__c'; String[] fieldNames = new String[] {}; ...


There's no way around it, you will need to write out Page_Id__r.App_Id__r.<field> for every field you want from your grandparent record. The best you'd be able to do is potentially save some typing by breaking out the query for granpdarent records into a separate query. You'll need to be the one to decide if it's worth it to expend an extra query and ...

Only top voted, non community-wiki answers of a minimum length are eligible