DF Process Automation an Logic P4 Flashcards

1
Q

A Salesforce developer noticed that an Apex method used in their custom Contact management application has been throwing null pointer exceptions on certain occasions.

Upon investigation, it was identified that the error was due to code that accesses the Account field of a Contact record, which may not be associated with an Account, and then calls the isSet method on the Account sObject.

Given a snippet of the code below, which of the following options can be used to avoid the exception?

public static void assignPrimaryContact() {
    Contact con = getContact();
    Boolean hasAssigned = con.Account.isSet('Has_Primary_Contact\_\_c');
    // ...
}

A.
~~~
Boolean hasAssigned = con.Account:Account.Has_Primary_Contact__c?null;
~~~

B.
~~~
Boolean hasAssigned = con.Account.?isSet(‘Has_Primary_Contact__c’);
~~~

C.
~~~
Boolean hasAssigned = con.Account?Account.Has_Primary_Contact__c:null;
~~~

D.
~~~
Boolean hasAssigned = con.Account?.isSet(‘Has_Primary_Contact__c’);
~~~

A

D.
~~~
Boolean hasAssigned = con.Account?.isSet(‘Has_Primary_Contact__c’);
~~~

The safe navigation operator can be used for replacing explicit checks for null references and uses the syntax “?.”, which is a question mark followed by a period. If the left-hand side of the operator evaluates to null, null is returned. Otherwise, the right-hand side, which can contain a method, variable, or property, is chained to the left-hand side of the operator and returned. In this case, the chained value is the ‘isSet’ method.

So, in the correct answer above, the resulting value that is returned to the ‘hasAssigned’ variable will be expressed as getContact().Account.isSet(‘Has_Primary_Contact__c’) if the contact is related to an account.

The other options contain invalid syntax or return values.

Safe Navigation Operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A junior Salesforce Developer at Global Containers is working on an after update trigger on the Opportunity object.

Given the code snippet below, what would be the result when a mass update is made to 200 Opportunity records with amounts over $1,000,000, assuming there is a user in the org with the role ‘Sales Manager’?

trigger OpportunityTrigger on Opportunity (after update) {
    User u = [SELECT Id FROM User WHERE UserRole.Name = 'Sales Manager' LIMIT 1];

    for (Opportunity o : Trigger.new) {
        if (o.Amount >= 1000000) {
            o.OwnerId = u.Id;
            update o;
        }
    }
}

A. Nothing since the code will not compile
B. A Final Exception will occur
C. A Limit Exception will occur
D. A DMLException Will ocurr

A

B. A Final Exception will occur

A FinalException error will be thrown when the code reaches the ownerId assignment line since ‘Trigger.new’ records can only be edited in ‘before’ triggers. The compiler will not detect this and the code will still be compiled.

Since the code never reaches the update DML operation, no LimitException or DmlException will occur.

Trigger Context Variables

Exception Class and Built-In Exceptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A Salesforce Administrator is working on a flow screen for capturing student registrations in a university. One requirement is that certain fields in the form should be displayed only when those fields are relevant or needed.

What feature can be used to meet this requirement?

Answer Choices:
A. Component visibility criteria can be defined on the screen components
B. Standard screen components should be used on the flow screen
C. Page Layouts can be assigned to the form based on state of screen components
D. Lightning record pages can be configured to control the visibility of screen components

A

A. Component visibility criteria can be defined on the screen components

Screen components can use conditional visibility filters which can be configured to make screen components visible if criteria are met. For example, a screen component can be made visible on the form only if a checkbox is ticked.

Conditional visibility filters are available for standard/custom/AppExchange screen components. Lightning record pages can be used to control the visibility of Lightning components, but not flow screen components. Page Layouts can only be assigned to record types.

Make Your Flow Screens Dynamic with Conditional Visibility

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Dynamic Activities is a tour agency that organizes group trips to climb mountains and explore dungeons. On the custom Reservation object, there is a custom picklist field that stores the type of activity. The picklist contains four values:

Mountain A

Mountain B

Dungeon A

Dungeon B

Apex code needs to be written so that, based on the activity type, a specific guide (User) is assigned to the reservation via a user lookup field.

Which statement will result in shorter and more readable code in this scenario?

Answer Choices:
A. SWITCH statement
B. FOR loop
C. IF-ELSE statement
D. SOQL FOR loop

A

A. SWITCH statement
When you have a fixed set of known values (like a picklist with 4 options), and need to execute different logic depending on each value, the switch statement in Apex is the best fit for clean and readable code.

Switch Statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Question (Rewritten in English):
A Salesforce Administrator for a digital marketing company has created a custom object called Expense and set its organization-wide default (OWD) sharing setting to Private.

The object is used for tracking and reimbursing expense claims. A Lightning page with a Flow was built to retrieve Expense records submitted by different users across the role hierarchy.

However, it was found that the flow is unable to return all Expense records because of sharing restrictions tied to the user’s role and the OWD setting.

What should be done to allow the application (the Flow) to retrieve all Expense records?

A. Set the flow to run in system context without sharing.
B. Invoke an Apex method to perform the record queries.
C. Enable the ‘Grant Access Using Hierarchies’ option.
D. Configure the Lightning page to run as an administrator.

A

A. Set the flow to run in system context without sharing.

A flow can be set to run in a system context without sharing. That means that the object-level permissions and field-level security of the running user will be ignored, as well as organization-wide default sharing settings, role hierarchies, sharing rules, manual sharing, teams, and territories.

Although an invocable Apex method can be used, it is not necessary as a declarative solution is available. The ‘Grant Access Using Hierarchies’ option, which is enabled by default for all objects, will provide access to records owned and shared by subordinates of the current user in the role hierarchy. But, it cannot open up access to records owned and shared by users above the current user in the role hierarchy. A configuration to run a Lightning page as a specific user is not available.

Run Flows That Bypass User Permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following queries shows a valid SOQL syntax for querying data from related standard objects?

Choose 1 answer.
A. SELECT Id, (SELECT Name, BillingState FROM Account WHERE Account.BillingState=’Arizona’) FROM Contact LIMIT 50
B. SELECT Name, Contact.LastName, Contact.FirstName FROM Account WHERE BillingState=’Arizona’ LIMIT 50
C. SELECT Name, (SELECT LastName, FirstName FROM Contact) FROM Account WHERE BillingState=’Arizona’ LIMIT 50
D. SELECT Name, (SELECT LastName, FirstName FROM Contacts) FROM Account WHERE BillingState=’Arizona’ LIMIT 50

A

D. SELECT Name, (SELECT LastName, FirstName FROM Contacts) FROM Account WHERE BillingState=’Arizona’ LIMIT 50

A relationship query is a query on multiple related standard or custom objects. To create a join in SOQL, a relationship between the objects is required. Using a relationship query, it is possible to traverse parent-to-child and child-to-parent relationships between objects to filter and return results. For example, a SOQL query that returns data from the Account object can also retrieve the first and last name of each contact associated with each account returned by the query.

Dot notation is used to reference fields from parent objects (e.g: SELECT Account.Name, Account.BillingState FROM Contact), while a nested SELECT statement is used to query child records. Dot notation can’t be used to query fields on child records, and nested SELECT statements can’t be used to retrieve parent data. Standard child relationship names use the plural form of the child object as the relationship name, so from an Account object, the relationship to Contact records is named Contacts.

Using Relationship Queries

Using Relationship Queries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following options contain valid variable initializations?

Choose 1 answer.
A. Decimal num = 12345; Double num = 1234.5;
B. Double num = 1234.5; Long num = 1.2345;
C. Integer num = 123.45; Decimal num = 12345;
D. Long num = 1.2345; Integer num = 123.45;

A

A. Decimal num = 12345; Double num = 1234.5;

Primitive numeric data types form a hierarchy where lower types can be implicitly converted to higher types such as Integer -> Long -> Double -> Decimal. In the example statement above, an Integer can be assigned to a variable of Decimal data type without explicitly converting it to Decimal because Integer is a lower type compared to the Decimal type. Any number with decimal values can be assigned to a Double data type as long as the number is within the minimum and maximum limits of the Double data type.

A number with decimal values cannot be implicitly converted to Integer or Long types since Double and Decimal are higher types compared to Integer and Long.

Primitive Data Types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The sales and support agents of Cosmic Supermarket frequently create account records manually in Salesforce. If the ‘Billing State’ of a new account is ‘New York’, then an email should be sent immediately to the manager of the account owner. In addition, a new task should be created and assigned to the account owner to reach out to the primary contact associated with the account. However, the task should only be created one week after the creation of the account. A Salesforce Administrator has decided to build a record-triggered flow for this requirement. What can be added to the flow to create the task record at a dynamically scheduled time?

Choose 1 answer:

A. Time-Dependent Action

B. Trigger

C. Scheduled Path

D. Apex Action

A

C. Scheduled Path

A part of a record-triggered flow can be run at a dynamically scheduled time after the triggering event occurs by adding a scheduled path to the flow. To meet this requirement, a scheduled path can be added and connected to a ‘Create Records’ element to create a task record 7 days after the ‘Created Date’ of a new account record. Note that a scheduled path can be configured to run before or after a specified number of minutes, hours, days, or months based on a specified Date/Time field on the triggering record. An email alert can be configured to be sent to the account owner’s manager immediately.

Using Apex is not necessary to schedule the creation of the task record. It is not possible to add a trigger to the flow. Time-dependent actions are available in workflow rules to schedule the execution of field updates, email alerts, task creation, or outbound messaging.

Run Part of a Record-Triggered Flow After the Triggering Event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A company uses Slack as its primary messaging tool for internal communications. The Sales Director wants to inform users whenever a new opportunity is created for one of their premium accounts by sending a notification in Slack. Which of the following is a valid consideration when using a custom notification to meet this requirement?

Choose 1 answer:

A. The company Slack workspace needs to authorize the action in Flow Builder

B. A Slack app does not need to be installed to distribute custom notifications in Slack

C. A Slack custom notification can be created and then sent using Flow Builder

D. A Slack-enabled notification type can be cloned and should be sent using Apex

A

C. A Slack custom notification can be created and then sent using Flow Builder

A Slack custom notification type can be created in Notification Builder in Setup. To support sending this type of notification, a Slack app such as the ‘Sales Cloud for Slack’ app, for example, needs to be installed in Slack and connected with the Salesforce account of the user. Once the Slack notification is created, the ‘Send Notification’ core action in Flow Builder can be used to send the notification when a new opportunity that meets the criteria is created.

Slack-enabled standard notifications can be cloned and sent using Flow Builder. Apex is not required to send Slack notifications unless complex logic is required. Authorizing the Flow Builder action in the Slack workspace is not a valid configuration step.

Create a Slack Notification

Ways to Send a Slack Notification

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A developer is creating a flow with a decision point that involves a Geolocation field. What should the developer keep in mind when working with Geolocations?

Choose 1 answer:

A. Equality and comparison operators can be used with Geolocation fields.

B. Only ISBLANK, ISCHANGED and ISNULL functions can be used in formulas dealing with Geolocation fields.

C. It is possible to specify a latitude without a longitude when saving a Geolocation field.

D. A Geolocation field is essentially a String data type used for storing coordinates.

A

B. Only ISBLANK, ISCHANGED and ISNULL functions can be used in formulas dealing with Geolocation fields.

Geolocation is a compound data type consisting of 2 components: Latitude and Longitude. A Geolocation field can either be completely blank or it must have both the latitude and longitude fields filled in. Because Geolocation is a compound data type, each of its components must be accessed separately for evaluation using a numeric data type such as a Double or Decimal. The only formula functions that work with Geolocation are ISBLANK, ISCHANGED, and ISNULL. Also, equality or comparison operators can’t be used with geolocations.

Compound Field Considerations and Limitations

Geolocation Custom Field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

An Apex trigger is subscribed to a platform event and generates invoice records upon receiving published event messages from an external order management system. However, an issue has been found with the record creation, and the Apex trigger needs to be modified. If it is required that no published event messages should be lost while the Apex trigger is being deactivated and fixed, which of the following should be performed?

Choose 1 answer:

A. Suspend the subscription of the Apex trigger to the platform event.

B. Schedule the receiving of platform event messages at a later date or time.

C. Deactivate the Apex trigger and pause the publishing of event messages.

D. Store any published event messages in a custom object temporarily.

A

A. Suspend the subscription of the Apex trigger to the platform event.

The Apex trigger needs to stop executing to prevent further issues in the org without losing any published event messages. To achieve this, the subscription of the trigger to the platform event can be suspended, which in this state, does not invoke the trigger to process any published event messages. The subscription can be resumed to either start with the earliest unprocessed event message when the subscription was suspended or process new event messages only.

Deactivating the Apex trigger or storing published event messages in a custom object is not required. Pausing the publishing of event messages is also not required and may not be feasible. Scheduling the receipt of platform event messages is not possible.

View and Manage an Event’s Subscribers on the Platform Event’s Detail Page

Manage Your Platform Event Trigger Subscriptions from the User Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Using the controller class below, what is the result after the following script is run:
ItemController i = new ItemController(); i.populate();

public class ItemController {

    public void populate() {

        Item\_\_c a = new Item\_\_c(Name = 'New Item');
        Database.insert(a, false); // partial success

        for (Integer x = 0; x < 150; x++) {

            Item\_\_c b = new Item\_\_c(Name = 'New Item');

            try {
                insert b;
            } catch (Exception e) {
                System.debug('DML limit reached');
            }
        }
    }
}

Choose 1 answer:

A. No records are created.

B. Only the first record is created because partial success is allowed.

C. “DML limit reached” is printed in the debug log.

D. The class cannot be instantiated because there is no constructor defined.

A

A. No records are created.

No records will be created. The total number of DML statements is 151, which exceeds the governor limit of 150. Since the limit is exceeded, all changes that occurred in the transaction will be rolled back.

Governor limit exceptions cannot be handled. So, the exception handler in the for loop will never be called. Even though partial success is set in the first insert statement, the record it created will be rolled back because it belonged to the same transaction. Constructors are not required in controllers, so the class can still be instantiated.

DML Statements vs. Database Class Methods

Classes, Objects, and Interfaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following represents a valid syntax of an interface implementation in Apex?

Choose 1 answer:

A. public interface MyInterface1, MyInterface2 {}

B. public class MyClass implements MyInterface1, MyInterface2 {}

C. public class MyClass extends MyInterface {}

D. public interface MyInterface {}

A

B. public class MyClass implements MyInterface1, MyInterface2 {}

Explanation:

In Apex (just like in Java), a class implements one or more interfaces, and extends a class (if there’s inheritance involved).

Correct Syntax:
To implement multiple interfaces:

public class MyClass implements MyInterface1, MyInterface2 {
    // Implementation of interface methods
}

Interfaces

Apex Class Definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the options below represents a valid method declaration in Apex?

Choose 1 answer:

A. static Boolean public method(String param) { … }

B. public static Boolean method(String param) { … }

C. public Boolean static method(String param) { … }

D. Boolean static public method(String param) { … }

A

B. public static Boolean method(String param) { … }

The proper syntax of declaring a method in Apex is:

` [public | private | protected | global] [override] [static] return_data_type method_name(param_data_type1 param_name1, …)`

An access modifier such as public, or private, is used but optional depending on the requirement. The override keyword can be added to the declaration to override methods in a class that has been defined as virtual or abstract. The static keyword can be used to enable the method to be called without instantiating the class. If the method returns a value, the data type of the returned value must be specified before the method name. Otherwise, the void keyword is used. Enclosed in parentheses, input parameters are separated by commas where each is preceded by its data type. If a method does not have parameters, an empty set of parentheses is used.

Class Methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A developer is chaining queueable jobs that perform callouts to an external endpoint. To avoid overloading the external system and minimize asynchronous Apex executions, a 10-minute delay must be added before each chained job runs. If myJob represents the queueable job, which of the following options shows the correct way to do this programmatically?

Choose 1 answer:

A. System.enqueueDelayedJob(600, myJob);

B. System.enqueueDelayedJob(myJob, 10);

C. System.enqueueJob(600, myJob);

D. System.enqueueJob(myJob, 10);

A

D. System.enqueueJob(myJob, 10);

Salesforce allows adding a scheduled delay to a queuable job using the System.enqueueJob() method. The delay value in minutes (minimum of 0 and maximum of 10) can be passed to the second parameter of the enqueueJob() method to determine the delay duration. Note that an org-wide default delay for all queueable jobs can be set in Setup > Apex Settings. Using the System.enqueueJob() method to delay a job overrides the org-wide default delay for the job.

Use the System.enqueueJob Method to Specify a Delay in Scheduling Queueable Jobs

Queueable Apex

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A developer needs to find all Contacts and Leads whose Title contains ‘VP’, and then update certain fields on these records. It’s determined that a SOSL query will be used.
Which of the following data return types should be used to store the result of the SOSL query in a variable?

Choose 1 answer:

A. List<List<Contact>></Contact>

B. List<List<Lead>></Lead>

C. List<List<SObject>></SObject>

D. List<SObject></SObject>

A

C. List<List<SObject>></SObject>

A SOSL query returns a list of lists of sObjects, which is why the result of a SOSL query should be stored in a variable of List<List<sObject>>. Each list contains the search result for a particular sObject type.

SOQL and SOSL Queries

17
Q

A developer at Cosmic Solutions is deleting test Lead records and emptying them from the recycle bin programmatically.
Given the code snippet below, what would be the result of the System.debug() statement if the SOQL query returns 5 records?

List<Lead> testLeads = [SELECT Id FROM Lead WHERE Name LIKE 'Test%' LIMIT 5];
delete testLeads;
Database.emptyRecycleBin(testLeads);
System.debug(Limits.getDMLStatements() + ' out of ' + Limits.getLimitDMLStatements() + ' DML statements used');

Choose 1 answer:

A. 5 out of 150 DML statements used

B. 2 out of 150 DML statements used

C. 10 out of 150 DML statements used

D. 6 out of 150 DML statements used

A

B. 2 out of 150 DML statements used

The delete DML statement above will only count as 1 towards the governor limit of DML statements regardless of the number of records contained in the list. Similarly, the Database.emptyRecycleBin() will also count as 1 such that the total number of DML statements issued at the end of the transaction will be 2.

The Limits.getDMLStatements() returns the number of DML statements that have been invoked up to the point in the code where it is called, whereas the Limits.getLimitDMLStatements() displays the governor limit for DML statements, which is 150. The Database.emptyRecycleBin() method can be used to permanently delete records from the recycle bin and can take a list of record Ids, an sObject, or a list of sObjects as parameters.

Execution Governors and Limits

getDMLStatements()

18
Q

If the DML operation below is performed, what is the expected result?

Lead master = [SELECT Id, FirstName, LastName FROM Lead LIMIT 1]; // returns 1 record
List<Lead> mergeList = [SELECT Id, FirstName, LastName FROM Lead LIMIT 3 OFFSET 1]; // returns 3 records

merge master mergeList;

Choose 1 answer:

A. The DML merge statement will throw an exception.

B. The records contained in mergeList will be reparented to the master record.

C. The master record will be merged into each record contained in mergeList.

D. The records contained in mergeList will be merged into the master record.

A

A. The DML merge statement will throw an exception.

The merge statement will throw an exception because the merge operation can only process up to three records at a time. The master record and the mergeList records have a combined size of four records.

In a successful merge scenario, records in the mergeList will be merged into the master record. After the merge, the records in mergeList will be deleted and any related records will be reparented.

Merging Records

19
Q

An invocable method is used to perform a callout that retrieves the latest currency exchange rates from a third-party web service. After a record is created in a screen flow, the invocable method is executed, and the record is then updated with the data returned by the callout.
Which of the following is a valid statement regarding the Transaction Control settings of this flow?

A. To avoid the uncommitted work pending error, the Transaction Control settings can be set to ‘Always continue in current transaction’.

B. To avoid the uncommitted work pending error, the Transaction Control settings can be set to ‘Always start a new transaction’.

C. If the method is not defined with a callout=true attribute, the callout will still be successful as long as the setting is set to ‘Let the flow decide’.

D. If the method contains the ‘callout=true’ attribute, the Transaction Control settings will be automatically locked to ‘Let the flow decide’.

A

B. To avoid the uncommitted work pending error, the Transaction Control settings can be set to ‘Always start a new transaction’.

When a callout is executed after a DML operation in a single transaction, the ‘uncommitted work pending’ error is thrown. Screen flows are capable of working efficiently around this limitation by executing the callout in a new transaction. If the ‘callout=true’ attribute is present in the invocable method annotation, the flow can be made aware that the method contains a callout. The flow can then be safely configured to let it decide at run time by explicitly setting the Transaction Control settings to ‘Let the flow decide’, which is the setting recommended by Salesforce. On the other hand, configuring the flow to always start a new transaction would also avoid the error since the method would always be executed in a new transaction regardless of whether it performs a callout.

Configuring the flow to always run the callout in the current transaction would throw the callout exception in this scenario. If the ‘callout=true’ attribute is not added to the invocable method annotation, the flow cannot determine that the method contains a callout. Hence, letting the flow decide for itself would eventually fail in this case.

Avoid Callout Errors in Screen Flows Automatically

Making Callouts to External Systems from Invocable Actions

20
Q

Cosmic Grocery sells various types of household items through its official online store. It uses Salesforce to manage the products. When a product is out of stock, one of the sales agents uses a flow in Salesforce to record certain details and send an email to a partner company with information like the required quantity of the product.

A sales user of the partner company, which does not use Salesforce, checks the email and initiates a new delivery process in an external application.

The delivery process should be initiated automatically in the external application after the required information is received from Salesforce. Although the application has automation tools, there is no mechanism to check for incoming emails.

When using a Platform Event to meet this requirement, which publish/subscribe logic should be utilized?

Choose 1 answer.

A. An Apex trigger should be used to publish the platform event message, and another Apex trigger should be used to subscribe to the message.

B. The flow used by the sales agents should be used to publish the platform event message, and an Apex trigger should be used to subscribe to the message.

C. The flow used by the sales agents should be used to publish the platform event message, and CometD can be used to subscribe to the message.

D. An Apex trigger should be used to publish the platform event message, and a flow should be used to subscribe to the message.

A

C. The flow used by the sales agents should be used to publish the platform event message, and CometD can be used to subscribe to the message.

In this scenario, Salesforce is the event producer and the external application is the event consumer. The flow used by the sales agents can be utilized to publish an event message when a product is out of stock. The external application used by the partner company can use CometD to subscribe to the platform event channel and receive event messages. It can initiate a new delivery process automatically based on the content of the event message. Note that the Pub/Sub API can also be used as an alternative method for subscribing external systems to platform events.

An Apex trigger can also be used to publish a platform event message. But a flow should not be used to subscribe to the message since the external application that needs to be the subscriber cannot rely on a flow to receive the message. Similarly, an Apex trigger should also not be used to subscribe to the message.

Publish Event Messages with Flows

Subscribe to Platform Event Notifications with CometD

Subscribe to Platform Event Notifications with Pub/Sub API

21
Q

A SOQL query needs to be performed that returns all the opportunities that are closing in the next 90 days. The results should only contain standard fields.
Which of the following SOQL statements can be used to meet the requirement?

Choose 1 answer.

A. SELECT FIELDS(ALL) FROM Opportunity WHERE CloseDate = NEXT_90_DAYS
B. SELECT FIELDS(STANDARD) FROM Opportunity WHERE CloseDate = NEXT_90_DAYS
C. SELECT Id, FIELDS(STANDARD) FROM Opportunity WHERE CloseDate = NEXT_90_DAYS
D. SELECT * FROM Opportunity WHERE CloseDate = NEXT_90_DAYS

A

B.
SELECT FIELDS(STANDARD) FROM Opportunity WHERE CloseDate = NEXT_90_DAYS

The FIELDS function in SOQL can be used to select fields without specifying the field names of the target sObject. To retrieve standard fields only, FIELDS(STANDARD) can be used. NEXT_90_DAYS is a date literal in SOQL that refers to all dates within the next 90 days.

FIELDS(ALL) is used to select both standard and custom fields in the results. To select custom fields only, FIELDS(CUSTOM) can be used. However, it is important to note that FIELDS(ALL) and FIELDS(CUSTOM) are supported in SOAP/REST API and Salesforce CLI only, and only if the result rows are limited by either specifying a LIMIT clause or using a WHERE clause that filters record IDs. The maximum number of allowed records that are returned in this case is 200 only

The asterisk(*), which is used to select all fields in SQL, is invalid and not supported in SOQL. The option “SELECT Id, FIELDS(STANDARD)…” would throw an error indicating duplicate fields in the query, since the Id field, which is a standard field, is already included in FIELDS(STANDARD)..

SELECT

Date Formats and Date Literals

22
Q

A record-triggered flow uses an invocable Apex method that performs a validation process over multiple related records when the value of the ‘Status__c’ field on the triggering record is changed. An update needs to be made to invoke different invocable methods, depending on the old and new values of the ‘Status__c’ field.

How should this requirement be handled?

Choose 1 answer.

A. Configure the record-triggered flow to access and compare the old and new values of the field and conditionally invoke methods.
B. Replace Flow Builder with Process Builder since processes can access old and new values of a record using the PRIORVALUE() function.
C. Replace the record-triggered flow with an Apex trigger that compares the old and new values of the field using the Trigger context variables.
D. Use the Assignment element in Flow Builder to enable the flow to access the old and new values of the field that triggered the flow.

A

A. Configure the record-triggered flow to access and compare the old and new values of the field and conditionally invoke methods.

A record-triggered flow that is configured to run when a record is created/updated, or updated only, is capable of accessing the previous values of the record that triggered the flow using the $Record__Prior global variable. By comparing the old and new values of the record using the $Record__Prior and $Record global variables, logic can be implemented to execute invocable methods accordingly using a Decision element.

Although Apex trigger or Process Builder can also be used to meet the goal, they are not necessary since the existing flow is capable of meeting the requirement. An Assignment element is not required in order to access old and new values of the record. In this scenario, Formula resources can be created and used in a Decision element to branch out to the different actions accordingly.

23
Q

Given the Apex class below, what will be the result if the code “Vehicle.checkDriver(17);” is executed?

Vehicle.checkDriver(17);

public class Vehicle {
    
    public virtual class VehicleException extends Exception {}
    public class AgeException extends VehicleException {}
    
    public static void checkDriver(Integer age) {
        try {
            if (age < 18) {
                throw new AgeException('Underage');
            }
        } catch (VehicleException e) {
            System.debug(e.getMessage());
        }
    }
}

A. The method will not be called as custom exceptions cannot extend each other.
B. An unhandled exception will occur since the handler does not match the error type.
C. The code will run successfully and ‘Underage’ will be printed in the debug log.
D. The class will not be compiled successfully as custom exceptions can’t be defined as virtual classes.

A

C. The code will run successfully and ‘Underage’ will be printed in the debug log.

The code will successfully compile and the method will be executed, which will print the string in the debug log.
To create a custom Exception class, the name of the class must end with ‘Exception’, and the class must extend the Exception class. Custom Exception classes can be defined as virtual classes so that they can be extended by another custom exception class.

Since the value of the parameter that was passed into the checkDriver method is below 18, the AgeException error will be thrown. Since AgeException extends VehicleException, the VehicleException catch block will be able to handle the error.

24
Q

A Salesforce developer at Cosmic Solutions is writing an Apex method that accepts an Account variable called ‘myAccount’, which represents an existing account record that has been queried from the database. After changes are made to the ‘myAccount’ fields in Apex, which statement should be used to save those changes to the database?

Choose 1 answer.

A. update myAccount
B. upsert myAccount
C. modify myAccount
D. save myAccount

A

A. update myAccount

The ‘update’ DML statement should be used as it is intended for saving updates to existing records. The ‘upsert’ statement is used to insert new records and update existing records in one call when there is a mix of new and existing records.

Other options (‘save’ and ‘modify’) are not valid DML statements. Although an ‘upsert’ statement can be used, it is not recommended as it can potentially create a new record instead of just updating an existing record only.

Data Manipulation Language

25
Cosmic Smart Solutions uses Salesforce for case management. A record of a custom object called 'Daily Case Log' is created programmatically at the beginning of each weekday. When a case is created or updated by a support agent: The 'Daily Case Log' record of the current day should be updated with the latest info about the number of closed cases. An email should be sent to an organization-wide email address used for system notifications. Which automation tool should be used for this requirement? Choose 1 answer. A. Apex trigger B. Assignment rule C. Flow Builder D. Case Escalation Rule
C. Flow Builder Flow Builder can: React to record changes (record-triggered flow). Query and update other records like the Daily Case Log. Send emails, including to organization-wide addresses. Use logic to determine how many cases are closed and update the correct record. This makes Flow Builder the perfect low-code tool for this automation. Flow Builder can be used to create an after-save record-triggered flow that is triggered automatically when a case record is created or updated. It can loop through all the closed cases, update a field on the 'Daily Case Log' record of the current day accordingly, and execute an action that sends an email to the organization-wide email address. Case Escalation Rule cannot be used on this requirement because there is no need to reassign a case to someone else nor notify an individual for late SLAs/SLOs. Note: SLA means Service Level Agreement. It is an agreement between a service provider and their clients that defines the level of service, the metrics by which the service is measured, and the remedies or penalties if the service level is not met. An example of this is an agreement between a Client and the BPO company that customer emails should be responded to within the first 5 hours from the time it is received. Once an email has been received, an incident/case is created in relation to that email.
26
Sales representatives in a furniture distribution center use a screen flow that guides them through a standardized follow-up process after quotes have been requested and received by customers. After a certain stage is reached in the flow, it should: Create a 'Job Order' record, and Perform an HTTP callout using an invocable method, which contains details of the job order, to a partner manufacturing company. Which of the following should be done to meet the requirement? A. Add the 'callout' attribute to the invocable method annotation and configure the Action in the flow accordingly. B. Use a Screen element in the flow after the record is created and before the invocable method is called in the flow. C. Ensure that the 'Create Records' element is immediately followed by the 'Action' element for the callout. D. Use a process instead of a flow Action element to call the invocable method after the record is created.
A. Add the 'callout' attribute to the invocable method annotation and configure the Action in the flow accordingly. In Apex, unless a savepoint was created (before the DML), a rollback was performed, and the savepoint was released (after the DML), performing a callout after a DML operation is not allowed and will throw an 'uncommitted work pending' error. However, screen flows are capable of working around this limitation by running the callout in a different transaction. The 'callout' attribute should be added to the invocable Apex method to make the flow aware that the Apex method performs a callout. Then, the Transaction Control settings of the Action element can be configured to let the flow decide how to run the method at run time. A Screen element can be inserted after the record creation to avoid the callout exception because the succeeding path after the screen is executed in a new transaction. However, this is no longer necessary due to the Transaction Control feature. If a process was used to fire the invocable method, the callout exception would still be thrown since it would still belong in the same transaction that was initiated by the flow. Note that Flow Builder also provides the HTTP Callout action, which is powered by External Services, in order to perform HTTP callouts without using Apex.
27
Cosmic Supermarket uses a custom object called 'Warehouse' to store information in Salesforce about the company’s warehouses. A custom Lightning record page has been created to allow users to view and edit warehouse information. Each warehouse record contains information about multiple warehouse managers and their email addresses. Each warehouse manager is assigned to one or more categories of products. Users who can access a warehouse record should be able to send an email to warehouse managers by specifying one or more product categories. In order to meet this requirement, a Salesforce Administrator is creating a screen flow that can be launched using a quick action on the Lightning page. Which of the following should be considered to ensure that the flow gets the required information from the warehouse record to send the email? A. An element needs to be added to the flow to get the warehouse record. B. An Apex action is required in the flow to access the warehouse record. C. The flow should use a record variable named recordId that is available for input. D. The Lightning page needs to be edited to enable passing the warehouse record to the flow.
C. The flow should use a record variable named recordId that is available for input. Cuando un Screen Flow se lanza desde un Quick Action en una página Lightning de registro, Salesforce automáticamente puede pasar el ID del registro al flow, si y solo si haces esto: Declaras una variable en el Flow llamada recordId La variable debe ser: Tipo: Text Disponibilidad: Available for input ✅ Con eso, el Flow recibe automáticamente el ID del Warehouse actual, y puedes usarlo para hacer consultas, enviar emails, etc.