PDI · Question #98
Ursa Major Solar has a custom object, serviceJob-o, with an optional Lookup field to Account called partner-service-Provider_c. The TotalJobs-o field on Account tracks the total number of…
The correct answer is B. Create a record-triggered flow on ServiceJob_o. The task is to efficiently keep a count field on an Account updated based on the number of related serviceJob__c records, where the relationship is an optional lookup.
Question
Ursa Major Solar has a custom object, serviceJob-o, with an optional Lookup field to Account called partner-service-Provider_c. The TotalJobs-o field on Account tracks the total number of serviceJob-o records to which a partner service provider Account is related. What is the most efficient way to ensure that the Total job_o field kept up to data?
Options
- AChange TotalJob_o to a roll-up summary field.
- BCreate a record-triggered flow on ServiceJob_o.
- CCreate an Apex trigger on ServiceJob_o.
- DCreate a schedule-triggered flow on ServiceJob_o.
How the community answered
(49 responses)- A12% (6)
- B80% (39)
- C2% (1)
- D6% (3)
Why each option
The task is to efficiently keep a count field on an Account updated based on the number of related `serviceJob__c` records, where the relationship is an optional lookup.
A roll-up summary field requires a master-detail relationship to directly aggregate data, which is not possible with an optional lookup field like `partner_service_Provider__c`.
A record-triggered flow on the `ServiceJob__c` object is the most efficient declarative solution. It can execute when a `ServiceJob__c` record is created, updated, or deleted to query and update the `TotalJobs__c` field on the related Account, handling the optional lookup relationship dynamically.
An Apex trigger could accomplish this, but a record-triggered flow is generally more efficient for this type of problem as it is a declarative solution, reducing development and maintenance overhead.
A schedule-triggered flow runs at predefined intervals, which would lead to delayed updates for the `TotalJobs__c` field, making it inefficient for real-time data synchronization.
Concept tested: Record-triggered flow for count aggregation on lookup relationships
Source: https://help.salesforce.com/s/articleView?id=sf.flow_builder.htm&type=5
Topics
Community Discussion
No community discussion yet for this question.