You need to sign in to do that
Don't have an account?
Ramana123
Can anyone help to write the nested map in below code , I am getting error
In the Second If-condition i am confued how to write the code can anyone help me in this how to write the code .
I am getting Account servicing records which are linked to account
public class Account_Related_Account_Servicing {
List<Account_Servicing__c> Accountservicing_records = new List<Account_Servicing__c>();
Map<Id,Map<Id,List<Account_Servicing__c>>> Account_RelatedRecords = new Map<Id,Map<Id,List<Account_Servicing__c>>>();
Map<Id,List<Account_Servicing__c>> listrecords = new Map<Id,List<Account_Servicing__c>>();
Public void Account_Linked_Account_Servicing_Records()
{
Accountservicing_records = [select Id,Account__r.Id,Name from Account_Servicing__c where Account__c != Null ];
for(Account_Servicing__c abc:Accountservicing_records)
{
if(listrecords.containsKey(abc.Id) )
{
listrecords.get(abc.Id).add(abc);
}
else
{
listrecords.put(abc.Id,new List<Account_Servicing__c>{abc}) ;
}
// In this how to write the code
if(Account_RelatedRecords.containsKey(Account__r.Id) )
{
Account_RelatedRecords.get(Account__r.Id).add(abc);
}
else
{
Account_RelatedRecords.put(Account__r.Id,Map<Id,List<Account_Servicing__c>>) ;
}
}
System.debug(Account_RelatedRecords);
}
}
I am getting Account servicing records which are linked to account
public class Account_Related_Account_Servicing {
List<Account_Servicing__c> Accountservicing_records = new List<Account_Servicing__c>();
Map<Id,Map<Id,List<Account_Servicing__c>>> Account_RelatedRecords = new Map<Id,Map<Id,List<Account_Servicing__c>>>();
Map<Id,List<Account_Servicing__c>> listrecords = new Map<Id,List<Account_Servicing__c>>();
Public void Account_Linked_Account_Servicing_Records()
{
Accountservicing_records = [select Id,Account__r.Id,Name from Account_Servicing__c where Account__c != Null ];
for(Account_Servicing__c abc:Accountservicing_records)
{
if(listrecords.containsKey(abc.Id) )
{
listrecords.get(abc.Id).add(abc);
}
else
{
listrecords.put(abc.Id,new List<Account_Servicing__c>{abc}) ;
}
// In this how to write the code
if(Account_RelatedRecords.containsKey(Account__r.Id) )
{
Account_RelatedRecords.get(Account__r.Id).add(abc);
}
else
{
Account_RelatedRecords.put(Account__r.Id,Map<Id,List<Account_Servicing__c>>) ;
}
}
System.debug(Account_RelatedRecords);
}
}
Can you elaborate on the use case with an example so as to check further and respond back.
Thanks.