Skip to main content
11 events
when toggle format what by license comment
Aug 21, 2020 at 20:07 comment added sfdcfox @Ajay Yes, you're right, I didn't test it with multiple relationships. Thanks for the notification! I've edited my answer.
Aug 21, 2020 at 20:07 history edited sfdcfox CC BY-SA 4.0
deleted 2 characters in body
Aug 21, 2020 at 19:34 comment added Ajay @sfdcfox: I figured out, one issue in the method ---- temp = record.getSObject(parts.remove(0));, it has to be temp = temp.getSObject(parts.remove(0));
Aug 20, 2020 at 20:42 comment added Ajay I am getting this error "System.SObjectException: Invalid relationship Site_Leader__r for Engagement__c"
Aug 20, 2020 at 20:41 comment added Ajay @sfdcfox I am using the same method and trying to get the value from grandparent. But I am getting error. String field = 'Learning_Community__r.Site_Leader__r.MATCH_User_Id_Auto__c'; List<String> fields = field.split('\\.'); List<sObject> acc = [SELECT Learning_Community__r.Site_Leader__r.MATCH_User_Id_Auto__c FROM Engagement__c WHERE Learning_Community__r.Site_Leader__c!=null LIMIT 1 ]; for(sObject s : acc){ system.debug(MATCH_MatchesDataReviewStudent.getValue(s, field)); //system.debug(s.getSobject('Learning_Community__r').getsObject('Site_Leader__r')); }
Jun 19, 2019 at 16:10 comment added sfdcfox @apple123 You'd need to have gotten the record in to a variable. The recursion is necessary otherwise.
Jun 19, 2019 at 16:00 comment added anxiousAvocado if I have 3 levels then this is returning null, like if I need a field Docman_Communication__c.PrimaryInformation__r.Account.Website_Active__c and here when we get Contact it also has Account as an ID and the getValue() method has to be called agian, but how do I avoid that recursive and get value from account?
Jun 19, 2019 at 15:19 comment added anxiousAvocado this worked perfectly. Thank you.
Jun 19, 2019 at 15:18 vote accept anxiousAvocado
Jun 19, 2019 at 14:08 comment added anxiousAvocado let me try this out, Thanks much for explaining much clearly.
Jun 19, 2019 at 13:46 history answered sfdcfox CC BY-SA 4.0