function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

update record(opportunityLitem) of child opportuity.....?

My scenario:

When i insert opportunity line-item on Parent Opportunity...opportunity line-item are also created on child opportunity(same as line-item on Opportunity).If there are 2 child opportunities then same opportunity line-items records will be created on both the child opportunity.

My problem is i have a button on opportunity when clicked on that a VF page opens and shows opportunity line-item records(editable) of parent opportunity.if i update any line-item record of parent opportunity then the child-opportunity line-item record should also be updated on all the child opportunities

As IDS of both opportunity line items records are different on child and parent opportunity. How to update child opportunity(opportunity line-item record) id parent opportunity opportunity line-item records are updated.

I am slightly should i do this..

I am able to able update the parent opportunity (opportunity line-item records). But how to update child-opportunity opportunity line-item records. Also I am able to get the ids of child opportunity opportunity line-item records.I dont know how to use them...Please help...

Shiv ShankarShiv Shankar

trigger updateChild on opportunity (after update){

   for(Opportunity O :{

   List<opportunity> listToUpdate = new List<opportunity>();

   List<opportunityLineItem> oliListToUpdae = new List<opportunityLineItem>();

    List<opportunity> opChildList = [select id, fieldToUpdate WHERE parentId =];

            for(opportunity op : opChildList){

                   op.fieldToUpdate = O.newUpdatedField;


                   for(opportunityLineItem oli : O.opportunityLineItems){

                               oli = O.O.newUpdatedField;




           update listToUpdate ;

            update oliListToUpdae;








// Try it once....with some modification.....