• Pruthvi Mada 5
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I want to add a new asset record to an existing List<Id, List<asset>>. The code doesn't throw any compile error or runtime error and the asset is not being added to the list. can someone please help ?

public class testList {
    
    public void testing()
    {
    List<Account> accountlst = [select id, (select id, name from assets) from account where account.id = 'xxxxxxxxxxxx'];
    system.debug('orig list'+ accountlst);
         system.debug('orig list'+ accountlst[0].assets);
    List<asset> bb = [select id, name, Asset_ID__c from asset where account.id = 'xxxxxxxxxxx' limit 2];
    accountlst[0].assets.add(bb[1]);
    system.debug('updated list'+accountlst);
        system.debug('updated list'+accountlst[0].assets);
    }    

}
I want to add a new asset record to an existing List<Id, List<asset>>. The code doesn't throw any compile error or runtime error and the asset is not being added to the list. can someone please help ?

public class testList {
    
    public void testing()
    {
    List<Account> accountlst = [select id, (select id, name from assets) from account where account.id = 'xxxxxxxxxxxx'];
    system.debug('orig list'+ accountlst);
         system.debug('orig list'+ accountlst[0].assets);
    List<asset> bb = [select id, name, Asset_ID__c from asset where account.id = 'xxxxxxxxxxx' limit 2];
    accountlst[0].assets.add(bb[1]);
    system.debug('updated list'+accountlst);
        system.debug('updated list'+accountlst[0].assets);
    }    

}