You need to sign in to do that
Don't have an account?

Field is not writeable: Paren-child
I have many to many relationship between 3 objects:
I want to insert list of sumarry(child) to parent object(accuunt)
Account acc = [Select ID, name,(SELECT id, Name FROM sumarry__r) from Account where name = 'apple'];
sumarry__c one = new sumarry__c();
sumarry__c two = new sumarry__c();
one.name = 'one';
two.name = 'two';
lists.add(one);
lists.add(two);
how to make it properly.
this operation acc.sumarry__r=lists cause
"Field is not writeable: sumarry__r"
or acc.sumarry__r.add(one) cause
'System.QueryException: List has no rows for assignment to SObject'
Account acc = [Select ID, name from Account where name = 'apple'];
sumarry__c one = new sumarry__c();
one.name = 'one';
one.Account = acc.Id;
sumarry__c two = new sumarry__c();
two.name = 'two';
two.Id = acc.Id;
lists.add(one);
lists.add(two);
Insert lists;
hope this helps!!
Are there any ways to get the same result via like mirror reflection through the parent object?