function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Santosh Shah 4Santosh Shah 4 

how to display value from parent & child both filed

I have parent to child query result stored in map now i want to display value from both obj  in VF email template using apex component but getting error

APEX CLASS LOGIC :

    public Map<Id, List<SObject>> getLocation()
    {
        Map<Id, List<SObject>> locationadd;
        for (account acc :[select id,Phone,(select City__c,State_Province__c,ZipCode__c FROM Addresses__r) from account where id ='xxxxxxxxxxxx'])
         {
          locationadd.put(p.Id, Addresses__r);
        }
         return locationadd;
   }     


APEX COMPONET:
 <apex:repeat value="{!Location}" var="acc4">   
   
   <TR>
      <TD>City</TD>
      <TD>{!Location[acc4].City__c}</TD>
   </TR>
      <TR>
      <TD>City</TD>
      <TD>{!Location[acc4].Phone}</TD>
   </TR>

 </apex:repeat> 
mukesh guptamukesh gupta
Hi Santosh,

please use  locationadd.put(p.Id, acc.Addresses__r)   instead of locationadd.put(p.Id, Addresses__r);

Please let me know if you need further help

Please Mark it As Best Answer If it Helps


Regards
Mukesh


 
Suraj Tripathi 47Suraj Tripathi 47

Hi Santosh,

You are filling the map in the wrong way. You can fill the map like this.

public Map<Id, List<SObject>> getLocation(){
        map<Id,List<Sobject>> locationadd=new Map<Id,List<Sobject>>();
        
        for(Account acc:[select id,Phone,(select City__c,State_Province__c,ZipCode__c FROM Addresses__r) from Account]){
            locationadd.put(acc.id,acc.Addresses__r);
        }
         return locationadd;
    }
 

Please follow the below link it will solve your all queries related to VF page

http://bobbuzzard.blogspot.com/2011/04/edit-parent-and-child-records-with.html

Please mark it as Best Answer so that other people would take reference from it.

Thank You!