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
Suraj_BahaleSuraj_Bahale 

Que

A company wants to create an employee rating program that allows employees to rate each other. An employees average rating must be displayed on the employee record. Employees must be able to create rating records, but are not allowed to create employee records.
Which two actions should a developer take to accomplish this task?
Choose 2 answers


A. Create a master- detail relationship between the rating and employee objects.
B. Create a trigger on the rating object that updates a field on the employee object.
C. Create a lookup relationship between the rating and employee object.
D. Create a rollup summary field on the employee and use AVG to calculate the average rating score.
Best Answer chosen by Suraj_Bahale
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi suraj,
B,C
Create a lookup relationship between the rating and employee object.
Create a trigger on the rating object that updates a field on the employee object.

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
 

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi suraj,
B,C
Create a lookup relationship between the rating and employee object.
Create a trigger on the rating object that updates a field on the employee object.

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
 
This was selected as the best answer
Arindam KunduArindam Kundu
Hi, 

Using A & D, we cannot achieve this scenario because though we can create master details relation between rating and employee, however, one rollup summary field cannot give us the average of the ratings for a particular employee. If we use 2 rollup summary field one to count the number of records and another to find the sum of records then using a formula field we can get the average rating on the employee record that means 3 fields just to get the average rating.
However, we can use A & B options that mean master-details relation between rating and employee and trigger on rating object to update the average rating field on the employee record. Ideally, all rating records should be deleted if an employee record gets deleted so option A seems suitable here.
Again, another scenario could be if we keep the master-details relation then employee record sharing will control rating record sharing that means all the rating records will be available to the rating giver which is not practical. 

So keeping a loose couple between employee and rating using lookup relation and then using a trigger to update average rating seems practical.

Thank you.