You need to sign in to do that
Don't have an account?
Create Trigger that updates an Opportunity field after the Account field has been edited/updated.
I have discovered that a workflow rule is not possible for a field update to the opportunity once the similar field is updated on the Account. (The field on the Opportunity only exists on a unique record type so no other Opps would be updated). Is there a simple trigger that can be created to accomplish this?
Our support team currently is tasked to update the field on the Opportunity which is tied to a workflow rule/field update that updates the associated field on the Account. Our Sales Manager would like the Sales Team to update the similar field on the Account and thus the Opportunity field would also get updated in the event the support team forgets to update the field.
The field name is: Clearing Account Status and it has three values:
Demo Account
Production Account
Demo and Production Account
Thanks for any assistance.
Is your field meant to have always the same value as the one on the account ?
If so, there is way simpler by creating a cross-object formula
Yes. Is they choose Demo Account on the Account record it should be Demo Account on the Opportunity.
Below is the trigger which which updates a field on the opportunity object in response to any update done oin the
account object
Trigger Modified on Account (before update) {
set<id>ids=new set<id>();
for(account acc:trigger.new)
{
ids.add(acc.id);
}
list<opportunity> k=new list<opportunity>();
if(ids.size()>0)
{
list<opportunity>opp=([select id,name,nextstep from opportunity where accountid in:ids]);
for(opportunity opplast:opp)
{
opplast.nextstep='Move Ahead';
k.add(opplast);
}
}
update k;
}
Thanks Rocket. I am very new to creating triggers and I am not exactly sure where the field name and values need to be added in the code. Also,will I have to have a seperate trigger for each of the three values in the picklist (similar to a workflow rule).
Field Name = Clearing Account Status
Values= Demo Account, Production Account, Demo and Production Account
John