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
RimaRima 

Updating fields in a Master object

Hi All,

I have created two objects student and attendance. Student is a master object and attendance is a detail object. I would like to pass some field value from Attendance to Student master object. Is it possible to update a field in a master object with the value from detail object? Could anyone please let me know weather I am in the right direction? Your help is greatly appreciated.

 

Ritesh AswaneyRitesh Aswaney

Not sure what exactly you mean by passing values, but here are a few initial thoughts.

 

- Rollup Summary Fields allow you to aggregate fields from a Child Object on the Parent Object (SUM, COUNT, AVG, etc)

 

- Cross Object workflows are possible in a Master-Detail relationship, i.e. if you have a workflow rule triggering off a Child Object, you are able to update fields on the Master Object.

 

Hope that helps.

RimaRima

Hi,

 

Thank you for your response. Student is a standard object, I have changed "contact" to "student" and "Attendance" is a custom object.I have a custom field "class" defined in both student and attendance. When I make change to "class" field in "Attendance" , I want "class" field in a "student" record to be updated.

 

I think  your second suggestion would work.

 

Cross Object workflows are possible in a Master-Detail relationship, i.e. if you have a workflow rule triggering off a Child Object, you are able to update fields on the Master Object.

 

could you please give me example of a trigger to update a field? Do I need to create workflow rule trigger on Master object or Child object? Your help is greatly appreciated.

Ritesh AswaneyRitesh Aswaney

You don't need an Apex trigger - workflows are pure config.

 

Create a Workflow rule triggering on an update to Attendance, add a field update which updates the relevant field on Student.

RimaRima

Hi,

 

Thank you for your response. Actually I created an Apex trigger on "Attendance" object and updated field in the master "Student" record. It is working now. I greatly appreciate your help.