PDI · Question #89
niversal Containers (UC) processes orders in Salesforce in a custom object, Crder_c. They also allow sales reps to upload CSV files with of orders at a time. A developer is tasked with integrating…
The correct answer is D. Callout from a queseatie class called from a trigger. To send individual order information to an ERP system via a REST endpoint when an Order__c status is first set to 'Placed', the developer should implement a Queueable Apex class called from a trigger.
Question
niversal Containers (UC) processes orders in Salesforce in a custom object, Crder_c. They also allow sales reps to upload CSV files with of orders at a time. A developer is tasked with integrating orders placed in Salesforce with UC's enterprise resource planning (ERP) system. After the status for an Craer__c is first set to "Placed', the order information must be sent to a REST endpoint in the ERP system that can process ne order at a time. What should the developer implement to accomplish this?
Options
- ACallout from an rare method called from a trigger
- BCallout from a Sarchabie class called from a scheduled job
- CFlow with 2 callout from an invocable method
- DCallout from a queseatie class called from a trigger
How the community answered
(42 responses)- A7% (3)
- B5% (2)
- C17% (7)
- D71% (30)
Why each option
To send individual order information to an ERP system via a REST endpoint when an `Order__c` status is first set to 'Placed', the developer should implement a `Queueable` Apex class called from a trigger.
A callout from an `@future` method (implied by 'rare method') called from a trigger is technically possible, but `Queueable` is generally considered a more robust and flexible pattern for asynchronous callouts from triggers, especially when complex data structures or chaining might be involved.
A `Schedulable` class called from a scheduled job is for time-based, batch processing, not for immediate, event-driven processing tied to a record's status change.
While a flow could invoke an Apex method, the core requirement is the asynchronous callout from the moment the status changes; an invocable method would still need to enqueue a `Queueable` or call a `@future` method, adding an extra layer.
A `Queueable` class can be invoked from a trigger to perform asynchronous callouts, which is necessary because direct callouts are not allowed from synchronous trigger contexts. `Queueable` Apex is well-suited for processing individual records or batches and making callouts, providing more flexibility than `@future` methods.
Concept tested: Asynchronous Callouts from Triggers
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm
Topics
Community Discussion
No community discussion yet for this question.