A developer is asked to build a solution that will automatically send an email to the customer when an Opportunity stage changes. The solution must scale to allow for 10,000 emails per day. The criteria to send the email should be evaluated after certain conditions are met. What is the optimal way to accomplish this?
Correct Answer: A
The optimal way to accomplish this requirement is to use an Email Alert with Flow Builder. An Email Alert is a workflow action that sends an email to one or more recipients that you specify. Flow Builder is a tool that lets you automate business processes by building flows that execute logic, interact with Salesforce, and call Apex classes. You can use Flow Builder to create a record-triggered flow that runs when an Opportunity stage changes and sends an email alert to the customer. This solution can scale to allow for 10,000 emails per day, as the daily limit for workflow and process email alerts is the greater of 1,000 or the number of user licenses in your org multiplied by 21. The criteria to send the email can be evaluated after certain conditions are met by using decision elements or formula resources in the flow2. Reference: Email Alerts, Flow Builder, Record-Triggered Flows
PDII Exam Question 17
Universal Containers wants to notify an external system, in the event that an unhandled exception occurs, by publishing a custom event using Apex. What is the appropriate publish/subscribe logic to meet this requirement?
Correct Answer: A
The appropriate publish/subscribe logic to meet this requirement is to publish the error event using the EventBus.publish() method and have the external system subscribe to the event using CometD. The EventBus.publish() method allows the developer to publish a custom event using Apex, and specify the event type, payload, and channel. The external system can use CometD, which is a scalable HTTP-based event routing bus, to subscribe to the event channel and receive the event notifications. The addError() method is not a valid answer, as it is used to display a custom error message on a record or a field, but it does not publish an event. The without keyword is not a valid answer, as it is used to ignore the sharing rules and permissions of the current user when accessing the records, but it does not affect the event publishing or subscribing. The event channel is not a valid answer, as it is the name of the channel that the event is published to or subscribed from, but it does not initiate the publish/subscribe logic by itself. Reference: [Publish and Subscribe to Platform Events Using Apex], [Subscribe to Platform Events Using CometD], [Apex Developer Guide]
PDII Exam Question 18
A company has a custom component that allows users to search for records of a certain object type by invoking an Apex Controller that returns a list of results based on the user's input. When the search is completed, a searchComplete event is fired, with the results put in a results attribute of the event. The component is designed to be used within other components and may appear on a single page more than once. What is the optimal code that should be added to fire the event when the search has completed?
Correct Answer: D
The optimal code that should be added to fire the event when the search has completed is Option D. This option uses the $A.get("e.c:searchComplete") method to get the event definition, the setParams() method to set the results attribute, and the fire() method to fire the event. The option also uses the cmp.getEvent("searchComplete") method to get the event definition, which is equivalent to the $A.get() method. Option A is incorrect, as it uses the $A.createComponent() method, which is used to create a component dynamically, not an event. Option B is incorrect, as it uses the $A.eventService.newEvent() method, which is deprecated and should not be used. Option C is incorrect, as it uses the $A.enqueueAction() method, which is used to invoke an Apex controller method, not an event. Reference: [Create and Fire Events], [Lightning Components Developer Guide]
PDII Exam Question 19
As part of point-to-point integration, a developer must call an external web service which, due to high demand, takes a long time to provide a response. As part of the request, the developer must collect key Inputs from the end user before making the callout. Which two elements should the developer use to Implement these business requirements? Choose 2 answers
Correct Answer: A,B
To implement the business requirements, the developer should use a Lightning web component and an Apex method that returns a Continuation object. A Lightning web component is a custom HTML element that can be used to create user interfaces for Salesforce apps. A Lightning web component can collect key inputs from the end user using various input components, such as lightning-input, lightning-combobox, or lightning-radio-group. A Lightning web component can also invoke an Apex method using the @wire decorator or the imperative Apex syntax. A Continuation object is a special Apex object that allows the developer to make a long-running request to an external web service and receive the response asynchronously. A Continuation object can specify the callback method, the timeout, and the request parameters for the callout. A Continuation object can also return a unique ID that can be used to reference the callout in the Lightning web component. To use a Continuation object, the developer should create and return a Continuation object in the Apex method that makes the callout, and annotate the method with @AuraEnabled(cacheable=true). The developer should also create and annotate another Apex method that acts as the callback method, and handles the response from the external web service. The developer should then invoke the Apex method that returns the Continuation object from the Lightning web component, and use the Continuation ID to track the status of the callout. The developer should also handle the callback event from the Apex method that acts as the callback method, and display the response data in the Lightning web component. Using a Screen Flow would not be effective, as a Screen Flow is a declarative tool that allows the developer to create guided, interactive processes for users, but it does not support making callouts to external web services. Using Process Builder would not be effective, as Process Builder is a declarative tool that allows the developer to automate business processes based on criteria and actions, but it does not support making callouts to external web services. Reference: [Lightning Web Components Basics], [Continuation Class]
PDII Exam Question 20
A developer created an Opportunity trigger that updates the account rating when an associated opportunity is considered high value. Current criteria for an opportunity to be considered high value is an amount greater than or equal to $1,000,000. However, this criteria value can change over time. There is a new requirement to also display high value opportunities in a Lightning web component. Which two actions should the developer take to meet these business requirements, and also prevent the business logic that obtains the high value opportunities from being repeated in more than one place? Choose 2 answers
Correct Answer: B,D
To meet the business requirements and prevent the business logic that obtains the high value opportunities from being repeated in more than one place, the developer should take two actions: create a helper class that fetches the high value opportunities, and use custom metadata to hold the high value amount. By creating a helper class, the developer can encapsulate the logic that queries the opportunities based on the high value amount, and reuse the same class in both the trigger and the Lightning web component. By using custom metadata, the developer can store the high value amount as a configurable value that can be retrieved by the helper class, and avoid hard-coding the value in the code. This way, the developer can also easily change the value in the future without modifying the code. Calling the trigger from the Lightning web component would not work, as triggers are not meant to be invoked directly from the user interface, and would also violate the separation of concerns principle. Leaving the business logic code inside the trigger for efficiency would not work, as it would create code duplication and maintenance issues when the same logic is needed in the Lightning web component. Reference: [Custom Metadata Types], [Apex Design Patterns]