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
TigerPowerTigerPower 

Update parent Opportunity with child Opportunity values

Hey everybody,

Could you please give me some advice with this:

We are creating child opportunities (cloning products too) with a custom button. When one of the child opportunities' stage is changed to closed/won, should this "winning" child update its parent opportunity.

Child opportunity has a look-up relationship to its parent.

 

I though that we could use another custom button to do the update with URLFOR code (a lot like the URLFOR we have for cloning the parent opportunity in the beginning). But the problem is that the button actually creates a new opportunity, not updates the "old" one.

 

What do you think, is a trigger the only way to update a parent?

 

Best Regards,

TP

werewolfwerewolf
A trigger would definitely be the best way to do this.  Also, do you really want to change the parent opportunity to closed/won when _one_ of the children is set to closed/won, or _all_ of them?  Just a thought.
TigerPowerTigerPower

Hello werewolf,

I don't want parent opportunity stage to change to closed/won. When one of the child's stage is closed/won, all the other children will be closed/lost. And the parent (stage) will be "Order from the client" when updated from the child.

 

So I'm trying to do this with urlfor and a custom button. I would need to add the parent opportunity id to syntax, but that might be unpossible to do. Other thought is to use $Action.Opportunity.edit instead of the clone. There I'm able to add parent opportunity id and update its fields, but then again, I don't get my products to follow. User may change / add more products at the child opportunity, and these changes have to be updated too.

 

This is my urlfor (clone)

 

{!URLFOR( $Action.Opportunity.Clone ,  Opportunity.Id,
[
cloneli=1,
RecordType="01220000000DX9M",
opp11="4 Order from the client",
opp14="",
opp10="",
opp3= Opportunity.Parent_Opportunity__c ,
CF00N20000001dhJ2=0,
CF00N20000001dhJ2_lkid=0,
CF00N20000001dhJ2_lkold=0,
CF00N20000001dhJ2_lktp=0,
CF00N20000001dhJ2_mod=""
],
true)}

 

Parent opportunity is different record type than its children. That information is also added to code.

 

Is there a trick to add that parent opportunity.id to this clone or use edit and get opportunity products also updated?

If not, what would be the best (easiest?!) way to start writing a trigger for this purpose?

 

Best Regards,

 

TP

Message Edited by TigerPower on 06-12-2009 01:33 PM
werewolfwerewolf

A trigger is still the best way to do this -- I'm not really sure how that URLFOR is working but it strikes me as being somewhat fragile.

 

As for where to start in writing the trigger, there's a fair bit of sample code here that updates parent records from a child and vice versa.