Process Automation & Logic Scenarios and Solutions 1 Flashcards
(4 cards)
A flow is created to perform an action based on the result of a complex computation involving a set of records. The records need to be retrieved using a query that requires multiple subqueries, where the results are processed and evaluated using a complex business logic. The outcome of the computation determines the next step that the flow should take.
An Apex class can be created with an invocable method that executes the necessary SOQL query for retrieving the records, processes the results based on the required logic, and returns the outcome. The Apex method can then be invoked by the flow
A sales director has requested an automation process that automatically converts a lead into an account and contact when the rating of the lead is updated to a certain value.
The Lead Convert Apex class can be used to convert the lead to an account and contact. It can also be used to convert a lead to a person account and business account simultaneously if the org meets the necessary configuration. A flow can be created to invoke the Apex method for the lead conversion when the record is updated and meets the required criteria.
An Apex class has been created as part of an org’s maintenance process that deletes certain records which meet a particular set of criteria. The Salesforce administrator would like to be able to modify or customize the deletion criteria whenever necessary.
Since flows are capable of deleting records, the deletion criteria and record deletion can be handled in a flow. This allows the criteria to be modified in Flow Builder and avoids the need to use code. The Apex then invokes the flow at the required point during the maintenance process.
Multiple Apex classes have been created that will be invoked in flows. Each class contains an invocable method which is designed to work with a specific type of sObject such as Account, Contact, etc. Although the sObject type handled in each invocable method is different, the business logic is the same. This resulted to repeated code contained in the different classes.
Invocable methods and invocable variables supports Object types. Instead of maintaining one class for each type of sObject, one Apex class can be used to handle multiple objects by modifying code to handle sObjects instead of a specific object type. The type of object can then be defined for each flow that uses the invocable method. This way, only one Apex classis required and maintained.