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
NishaCNishaC 

Problem Map.get()

Hii 

i am using this list

List<Service__c> srList= [select id, Name, Customer__c,Days_Collection__c,Status__c, 
Service_Start_Date__c,s.Customer__r.Grand_Parent_Account__c
from Service__c s where Status__c = 'Active' AND Days_Collection__c!=null AND Customer__c!=null];


map<id,Decimal> mapgrandParentsCounts = new map<id,Decimal>();
for(Service__c sr:srList)
{
if(mapgrandParentsCounts.containskey(sr.Customer__r.Grand_Parent_Account__c) && sr.Name!=null) 
{
Decimal tCount = mapgrandParentsCounts.get(sr.Customer__r.Grand_Parent_Account__c);
tCount = tCount + finalCount;
mapgrandParentsCounts.put(sr.Customer__r.Grand_Parent_Account__c,tCount);
}
else
{
mapgrandParentsCounts.put(sr.Customer__r.Grand_Parent_Account__c,finalCount);
}
}

for(id gpAcc : mapgrandParentsCounts.keyset()) {
//here i want Name, city and address of this id
any idea
}

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

RoyGiladRoyGilad

I think the easiest way to solve this will be to collect all account IDs into a list and to add a query (with the wanted fields) on the Account table into a Map (accMap), and then to 

extract it from this map with you want to display the data.

 

//getting the revevent account

Account a = accMap.get(gpAcc );

 

Hope that helps,

NishaCNishaC

i have already done this

but from this m only getting account ids

but i want service object City, Address with respect to account id

give me some idea for this