You need to sign in to do that
Don't have an account?
Pruthvi Mada 5
adding a new record to List<account.id, List<asset>>
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);
}
}
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);
}
}
Looks like this is not possible. check this link:
https://salesforce.stackexchange.com/questions/7731/is-a-list-from-a-subquery-modifiable
Anyways, thanks for looking into this.