Shivangi Singh
Shivangi Singh

Reputation: 1

Best approach to update a field in Parent object if any update is happening on either of the object

I have to 2 object having master-detail relationship.  I want to update a Status picklist field in Parent object if any update is happening on either of the object (Parent or child). What will be the best approach?

Upvotes: 0

Views: 2120

Answers (1)

Aleena
Aleena

Reputation: 43

Hope this helps give you some idea of the various solutions available. I've ordered them by simplest workflow updates to more complex process builders and lastly apex triggers, which resonates the best practice of clicks over code when implementing solutions on salesforce.

You can use a number of strategies here, I'll outline them below from simplest to complex (overkill):

  1. Workflow: You can use two workflow field updates to do this:
- one on the parent object when a record is edited, 
  then update the status picklist field on the record .

- and another on the child object when a record is edited,
  then upon selecting `field to update` as option, you will
  be given the parent object and child object as options to
  filter fields on, select parent object to filter fields on
  then select the status picklist field from parent object.
  1. Process Builder: You can use process builder to update parent record from child.
Create a process builder flow on child object and update parent
object along with either of the two:

- create a workflow on the parent object to update the status
  picklist field when a record is edited only.
- or alternatively to the workflow on the parent object, create
  a process builder flow on parent object and update parent object.
  1. Apex Trigger:
Equally you can go to the lengths of writing an apex trigger
upon the parent object `onupdate` trigger and verify if a valid
change was made(meaning the change made to parent was not a
change on the status picklist field), update the the status
picklist field too.

Upvotes: 1

Related Questions