0

i'm having big troubles to fill a map with the data of fields of related objects to the one that is declared as value.

Map<Id,GPMIR_obj_energyLead__c> mapToMap = new Map<Id,GPMIR_obj_energyLead__c>([SELECT Id, 
    IdCommunity__c, 
    Community__c, 
    Community__r.name__c, 
    Community__r.installation__r.CUPSInmueble__r.StreetSP__c, 
    Community__r.partitionCoefficient__c
FROM GPMIR_obj_energyLead__c
WHERE Id IN : mapRelateLeadsWithCommunities.keySet() 
AND IdCommunity__c IN : mapRelateLeadsWithCommunities.values()]);

Here we have three objects:

  1. GPMIR_obj_energyLead__c
  2. SM_Community__c
  3. SM_Installation__c
  4. PointOfDelivery__c

Every one of them is the many in a many to one relationship with the next one in the list

When i debug the Map i'm only getting the fields of GPMIR_obj_energyLead__c (Id,IdCommunity__c,Community__c)

The query is right is SOQL, but there is something wrong in the development

Any idea of what am i doing wrong?

  • 1
    the system.debug line won't show the parent recs; you need to use a bit of apex to show the parent fields – cropredy Jan 23 at 22:59
1

This is a "feature" of System.debug of an sobject

A way to verify:

String[] debugLines = new List<String>();
for (ID recId : mapToMap.keySet() ) {
  GPMIR_obj_energyLead__c rec = mapToMap.get(recId);
  debugLines.add(rec + ' ' + rec.Community__r.Name__c +  ' ' +  ....);
}

System.debug(String.join(debugLines,'\n');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.