You need to sign in to do that
Don't have an account?
Mktdev
Nested Query Update
I am trying to update Parent and child object using Nest Query but child records are not getting saved.
Public List<Account> getAccount(){ list<Account> acc = [select Id, Name,Country, (select Id, FirstName,LastName,Email from contact) from account where Id=: a.Id]; return acc; }
<apex:repeat var="a" value="{!Account}"> <apex:outputText value="{!a.Name}"/> <apex:repeat var="c" value="{!a.Contacts}"> <apex:inputfield value="{!c.FirstName}"> <apex:inputfield value="{!c.LastName}"> <apex:inputfield value="{!c.Email}"> </apex:repeat> <apex:repeat>
update acc [0].Contacts;
Or
list<contact> con = new list <contact>();
for(Account TempAcc : acc )
{
con.addall(TempAcc.Contacts);
}
update con;
All Answers
update acc [0].Contacts;
Or
list<contact> con = new list <contact>();
for(Account TempAcc : acc )
{
con.addall(TempAcc.Contacts);
}
update con;
Thanks SRK!
Yes, Iater I also figured it out we have to iterate our the subset to update the child records.
Still thanks for responding.!