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
Shannon Andreas 1Shannon Andreas 1 

Trigger help - changing picklist value of one object based on picklist value change on another object

Hello,

I am trying to figure out if I need a trigger to update a field on the Account object when a field on the Contract object changes. 

For example, 

When Contract field, Status = "Activated", change Account field, Type to "Customer"

There is a relationship beteen the account and contract objects.

Thanks!


Shannon

Pankaj_GanwaniPankaj_Ganwani
Hi,

There would be one use case. If on insert of on Contract record having status='Activated' then corresponding Account will have type = 'Customer'. If we insert another contract record corresponding to the same account then what should be the type on Account?
Hargobind_SinghHargobind_Singh

Hi, to answer your question,, yes a trigger would be required as you are updating the field of Account object when Contract object is being updated. 
 

Vi$hVi$h
Hi Shannon,

Yes you could write a trigger but trigger is not the only option. Take a look at the process builder also for this.
It is similar to a workflow with additional features. Using process builder you can "Update any related record—not just the record or its parent".
https://help.salesforce.com/HTViewHelpDoc?id=process_overview.htm
Advantage of using a process builder over a trigger 
1 .No code
2. No code coverage :)

Thanks,
Vishal