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

Update Stage name from opportunity line item to opportunity
Hi,
I have a field called Stage in opportunity product object and values are same as the opportunity stage.
An opportunity can have multiple line items.
In terms of logic, the stage on the Opportunity should be the lowest stage amongst stages of line item.
E.g.: If there are 3 line items with stages: 4, 5, 7 ( I am not using exact stage names for sake of simplicity) then stage value on the Opportunity should be 4.
Its kind of urgent.Please let me know how to do it.
Thanks.
I have a field called Stage in opportunity product object and values are same as the opportunity stage.
An opportunity can have multiple line items.
In terms of logic, the stage on the Opportunity should be the lowest stage amongst stages of line item.
E.g.: If there are 3 line items with stages: 4, 5, 7 ( I am not using exact stage names for sake of simplicity) then stage value on the Opportunity should be 4.
Its kind of urgent.Please let me know how to do it.
Thanks.
1. Create an after trigger on OLI
2. Get all the other OLI's related to the Parent opportunity based on Opportunityid field.
3. Declare a Set variable with string datatype and add all the stage names of the related OLI's
4. Use if else conditions to see if the set contains the stagename starting with the least stage name and ending with the highest. Within ifelse update the Opportunity stage.
Hope this helps.