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
NANCY1NANCY1 

update master field based on all detail records?

Hi,

 

I have a master field that need to get updated based on all detail records.

 

In the detail records i have the status field, if for all the detail records value of the Status field is "Closed" then the master field value should also be closed.. (i.e. the value of the master field will be "closed" only if all detail records are "closed")

 

how can i achieve that...

 

saraha@groupesci.comsaraha@groupesci.com

You will need to use a trigger on the detail object whenever it is updated or inserted. Get the master record, then get all details for that master and update if necessary.  Be careful to make sure your trigger is bulkified.

 

--Sarah

MiddhaMiddha

Follow these steps to achieve this with configuration but only if you have a Master-Detail relationship in your objects else you have to write a trigger only:

 

1. Create a Rollup field on Master object which COUNTS records macthing your given criteria i.e. where Status = Closed

2. Create a workflow on Master object that executes evrytime a records is created or edited and matches criteria i.e. Rollup field > 0

3. Create a field update that updates your field on Master object to Closed.

 

 

Ritesh AswaneyRitesh Aswaney

I'm not sure that you can fire a workflow off a Rollup Summary Field value changing.

 

I'd change step 2 to read

Create a Workflow on the Detail object  that executes every time a records is created or edited and matches criteria i.e. Master.Rollup field > 0

 

Cross Object Workflows can fire off the Detail and Update Master. 

 

MiddhaMiddha

Ritesh,

 

I tried those steps and those are working , you can fire a workflow on a Rolup summary field. Having a workflow on master works.