0

I'm querying an object(Custom_Obj_A) and some other fields from lookup object(Custom_Obj_B) using soql. These fields are then stored in Map<Id,Custom_Obj_A)>. I also want to utilize the fields from Custom_obj_B but the map only stores fields from Custom_obj_A (which is as expected). Is there a way to also store the fields of custom_obj_B ?. As of now, i'm looping through the query and adding the fields to Custom_obj_b list. Looking for a better option on this.

Thanks in advance.

1
  • 2
    Could you share your query and iteration code? It makes it easier to answer... Commented May 12, 2022 at 10:44

1 Answer 1

1

If you're using System.debug to check the map values, you should be aware that child and parent relationships aren't printed out. The values are there, you just need to access them as normal:

// Parent
myMap.get(someRecordId).CustomObjectB__r.SomeField; 
// Child
myMap.get(someRecordId).CustomIbjectB__r.size();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .