Salesforce Platform Developer I (legacy) — Question 189
Ursa Major Solar has a custom object, ServiceJob_c, with an optional Lookup field to Account called Partner_Service_Provider_c.
The TotalJobs_c field on Account tracks the total number of ServiceJob_c records to which a partner service provider Account is related.
What is the most efficient way to ensure that the TotalJobs_c field is kept up to date?
Answer options
- A. Create an Apex trigger on ServiceJob_c.
- B. Change TotalJobs_c to a roll-up summary field.
- C. Create a record-triggered flow on ServiceJob_c.
- D. Create a schedule-triggered flow on ServiceJob_c.
Correct answer: C
Explanation
The most efficient method is to create a record-triggered flow on ServiceJob_c, as it automatically updates the TotalJobs_c field whenever a ServiceJob_c record is created, updated, or deleted. An Apex trigger could work but requires more coding effort and maintenance. A roll-up summary field is not applicable here since it cannot count records for a Lookup field, and a schedule-triggered flow would not provide real-time updates.