100% found this document useful (1 vote)
162 views23 pages

Apex Process Automation Exam Prep

This document provides an overview of a certification preparation module focused on process automation and logic for the Salesforce Platform Developer I exam. The module contains three units that review Apex constructs like variables, methods, and interfaces. It includes interactive practice questions similar to those on the exam. Downloads are available for a printable guide. Flashcards cover key topics, and related badges direct students to additional learning materials. The process automation and logic section makes up 38% of the exam.

Uploaded by

Wasim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
162 views23 pages

Apex Process Automation Exam Prep

This document provides an overview of a certification preparation module focused on process automation and logic for the Salesforce Platform Developer I exam. The module contains three units that review Apex constructs like variables, methods, and interfaces. It includes interactive practice questions similar to those on the exam. Downloads are available for a printable guide. Flashcards cover key topics, and related badges direct students to additional learning materials. The process automation and logic section makes up 38% of the exam.

Uploaded by

Wasim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Platform Developer I Certification Prep: Process Automation and Logic

Unit 1: Review Basic Constructs in Apex


Learning Objectives
After completing this unit, you'll be able to:

• Use and apply Apex control flow statements.


• Describe the capabilities of the declarative process automation features

Key Topics
This module prepares you for the logic and process automation section of the Platform Developer I exam. The
process automation and logic section, which makes up 38% of the overall exam. In this unit we will review
these topics.

• Apex variables and constants


• Apex methods
• Interfaces

This module includes a number of interactive, real-world, scenario-based questions that are a lot like the ones
you can encounter as a Salesforce developer. Looking at these scenarios helps prepare you to take the
process automation and logic section of the Platform Developer I exam. As you tackle the practice questions,
you get immediate feedback on your answers, along with detailed information on why your answers are correct
(or incorrect).

This module includes three units on process automation and logic. This unit focuses on the basic constructs
within Apex.

Download the Guide


Would you like a hard copy of the contents in these modules? Each module includes a link to a printable
version you can download. Download the Platform Developer I Certification Prep: Process Automation and
Logic guide.

Exam Practice Questions


Ready to jump in? The sample tool below is not scored—it’s just an easy way to quiz yourself. To use it, read
the scenario and click the answer you think is correct. Some questions may have more than one correct
answer. Click Submit and you get a popup telling you whether the answer you chose is correct or incorrect,
and why; if there’s a longer explanation, click and then click anywhere in the window to close it. When you
reach the end, you can review the answers or retake the questions.

1
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 1
When the number of records in a recordset is unknown, which control statement should a developer use to
implement a set of code that executes for every record in the recordset, without performing a .size() or .length()
method call?

ANSWER FEEDBACK

Incorrect. For do while, while, and traditional for loops, the


A. DO { … } WHILE (CONDITION) developer must set the size value for the exit condition to
eventually be met.

Incorrect. For do while, while, and traditional for loops, the


B. WHILE (CONDITION) {...} developer must set the size value for the exit condition to
eventually be met.

Incorrect. For do while, while, and traditional for loops, the


C. FOR (INIT_STMT; EXIT_CONDITION;
developer must set the size value for the exit condition to
INCREMENT_STMT) { … }
eventually be met.

Correct. List or set iteration for loops do not need the


D. FOR (VARIABLE : LIST_OR_SET) { … }
size of the collection to run.

2
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 2
What is the value of x after the code segment executes?
String x = 'A';

Integer i = 10;

if ( i < 15 ){

i = 15;

x = 'B';

} else

if ( i < 20 ){

x = 'C';

} else {

x = 'D';

ANSWER FEEDBACK

Incorrect. These if statements are evaluating the


A. 'A' value of i. Based on the if statements the value of x
will always be modified.

Correct. These if statements are evaluating the


value of i. Since i is equal to 10 then i is less than
B. 'B' 15 and i will be reassigned the value 15 and x will
be equal to 'B'. Once the values are assigned the
if statement is no longer run.
Incorrect. These if statements are evaluating the
value of i. The value of x could be equal to ‘C’
because i is in fact less than 20. However, since this
C. 'C'
condition is in the else portion of the if else
statement, the condition (i < 20) is never reached
because the previous condition (i < 15) is met.
Incorrect. These if statements are evaluating the
value of i. The only way that x will be equal to 'D'is
D. 'D' if all of the other conditions are false. Being that i is
less than 15 and i is also less than 20 this else
condition is never reached.

3
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 3
Which three are accurate statements about variable scope? (Select three answers.)

ANSWER FEEDBACK

A. A VARIABLE CAN BE DEFINED AT ANY POINT IN Correct. A variable is valid from the point
A BLOCK. where it is declared inside of the code.

Correct. Variables can be defined anywhere


B. SUB-BLOCKS CANNOT REUSE A PARENT within a block. However Sub-blocks can’t
BLOCK'S VARIABLE NAME. redefine a variable name that has already been
used within a parent block.

Incorrect. Variables can be defined anywhere


C. SUB-BLOCKS CAN REUSE A PARENT BLOCK'S within a block. However Sub-blocks can’t redefine
VARIABLE NAME IF ITS VALUE IS NULL. a variable name that has already been used within
a parent block regardless if the value is null.

Correct. The same name can be used inside


D. PARALLEL BLOCKS CAN USE THE SAME parallel blocks because the scope of the
VARIABLE NAME. variable is limited only to the particular block
that it was defined in.

E. A STATIC VARIABLE CAN RESTRICT THE Incorrect. The value of a static variable persists
SCOPE TO THE CURRENT BLOCK IF ITS VALUE IS within the context of a single transaction and is
NULL. reset across transaction boundaries.

4
Platform Developer I Certification Prep: Process Automation and Logic

Exam Topic Flashcards


Use the interactive flashcards in each unit to brush up on some of the key topics you’ll find on this portion of
the exam.

Read the question or term on each card, then click the card to reveal the correct answer. Click the right-facing
arrow to move to the next card, and the left-facing arrow to return to the previous card.

Question/Term Answer/Definition
Which two users can edit a
An administrator and a user who is
record after it has been
assigned as the current approver
locked for approval?

What happens to changes in the


result when a Visualforce page calls
Any changes up to the error are
an Apex controller, which calls
rolled back.
another Apex class, and then hits a
governor limit?

5
Platform Developer I Certification Prep: Process Automation and Logic

Related Badges

Looking for more information? Explore these related badges.

Badge Content Type

Module

Apex Basics & Database

Next, let’s review the second part of the process automation and logic section of the Platform Developer I
exam.

6
Platform Developer I Certification Prep: Process Automation and Logic

Unit 2: Get a Refresh on SOQL, SOSL, and DML


Learning Objectives
After completing this unit, you'll be able to:
• Given a scenario, write SOSL, SOQL and DML statements in Apex.
• Identify the implications of governor limits on Apex transactions.
• Implement exception handling in Apex, including custom exceptions as needed.

Key Topics
This unit prepares you for these topics in the logic and process automation section of the Platform Developer I
exam.

• SOQL
• SOSL
• DML
• Exceptions and governor limits

Exam Practice Questions


Ready to jump in? The sample tool below is not scored—it’s just an easy way to quiz yourself. To use it, read
the scenario and click the answer you think is correct. Some questions may have more than one correct
answer. Click Submit and you get a popup telling you whether the answer you chose is correct or incorrect,

and why; if there’s a longer explanation, click and then click anywhere in the window to close it. When
you reach the end, you can review the answers or retake the questions.

7
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 1
A developer in a Salesforce org with 100 accounts executes the following code using the Developer Console.

Account myAccount = new Account(Name='MyAccount');


insert myAccount;

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


Account newAccount = new Account(Name='MyAccount' + x);
try{
insert newAccount;
}catch (Exception ex){
System.Debug(ex);
}
}

insert new Account(Name='MyAccount');

How many accounts are in the org after this code is run?

ANSWER FEEDBACK

Correct. Salesforce has a governor limit of 150 DML statements per


transaction. The Salesforce org originally starts with 100 accounts. The
first DML statement inserts the first account leaving 149 DML
statements available. Inside the for loop it tries to make 150 DML
A. 100 statements. But the limit is reached when x = 149. When this happens the
transaction aborts and all data changes are rolled back. The only thing
that is left is the original 100 accounts. Since the error happened the last
insert statement is never reached. Best practice is to avoid DML
statements inside for loops.

Incorrect. Salesforce has governor limits of 150 DML statements per


B. 101 transaction. When the limit is reached, the transaction aborts and all changes
are rolled back. Best practice is to avoid DML statements inside for loops.

Incorrect. Salesforce has governor limits of 150 DML statements per


C. 102 transaction. When the limit is reached, the transaction aborts and all changes
are rolled back. Best practice is to avoid DML statements inside for loops.

Incorrect. Salesforce has governor limits of 150 DML statements per


D. 252 transaction. When the limit is reached, the transaction aborts and all changes
are rolled back. Best practice is to avoid DML statements inside for loops.

8
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 2
Which two statements should a developer avoid using inside procedural loops? (Select two answers.)

ANSWER FEEDBACK

Correct. Avoid using SOQL in loops since there is a


governor limit that enforces a maximum number of
A. LIST<CONTACT> CONTACTS = [SELECT
SOQL queries. When these operations are placed
ID, SALUTATION, FIRSTNAME, LASTNAME,
inside a loop, database operations are invoked once
EMAIL FROM CONTACT WHERE
per iteration of the loop making it very easy to reach
ACCOUNTID = :A.ID];
these governor limits. Best practice is to query once
to obtain all results, and then iterate over the results.

Correct. Avoid using DML in loops since there is a


governor limit that enforces a maximum number of
DML statements. When these operations are placed
B. UPDATE CONTACTLIST;
inside a loop, database operations are invoked once
per iteration of the loop making it very easy to reach
these governor limits.

Incorrect. An if statement can be used inside of a loop to


C. IF (O.ACCOUNTID == A.ID)
create a condition.

D. SYSTEM.DEBUG('AMOUNT OF CPU
Incorrect. System.debug is a great way to test the output
TIME (IN MS) USED SO FAR: ' +
especially in loops.
LIMITS.GETCPUTIME());

9
Platform Developer I Certification Prep: Process Automation and Logic

Exam Topic Flashcards


The following flashcards cover SOQL, SOSL, exceptions, and governor limits. Use these interactive flashcards
to review some of the key topics you’ll find on this part of the exam.

Read the question or term on each card, then click on the card to reveal the correct answer. Click the right-
facing arrow to move to the next card, and the left-facing arrow to return to the previous card.

Question/Term Answer/Definition
Which data structure is returned to a developer
A list of lists of sObjects
when performing a SOSL search?

A developer runs the following anonymous code


block.

List<Account> acc = [SELECT Id FROM


Account LIMIT 10];

Delete acc;
2,150
Database.emptyRecycleBin(acc);

system.debug(Limits.getDMLStatements()+',
'+Limits.getLimitDMLStatements());

What is the result?

A developer has the following query.

Contact c = [SELECT id, firstname,


lastname, email FROM Contact WHERE
lastname = 'Smith']; An error that no rows are found.

What does the query return if there is no contact


with the last name Smith?

A developer writes a Salesforce Object Query Language


(SOQL) query to find child records for a specific parent. 1
How many levels can be returned in a single query?

10
Platform Developer I Certification Prep: Process Automation and Logic

Related Badges

Looking for more information? Explore these related badges.

Badge Content Type

Module

Database &.NET Basics

Module

Search Solution Basics

Great work! You’re almost finished reviewing the process automation and logic section of the Platform
Developer I exam. On to the last unit, which covers Apex classes and triggers.

11
Platform Developer I Certification Prep: Process Automation and Logic

Unit 3: Study Up on Apex Classes and Triggers


Learning Objectives
After completing this unit, you'll be able to:
• Write Apex classes and use Apex interfaces.
• Write Apex classes and triggers while following best practices.
• Describe the relationship between Apex transactions, the save order of execution, and the
potential for recursion and cascading.

Key Topics
This unit prepares you for these topics in the logic and process automation section of the Platform Developer I
exam.

• Apex classes
• Apex triggers
• Save order of execution

Exam Practice Questions


Ready to jump in? The sample tool below is not scored—it’s just an easy way to quiz yourself. To use it, read
the scenario and click the answer you think is correct. Some questions may have more than one correct
answer. Click Submit and you get a popup telling you whether the answer you chose is correct or incorrect,
and why; if there’s a longer explanation, click and then click anywhere in the window to close it. When you
reach the end, you can review the answers or retake the questions.

12
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 1
What is an accurate constructor for a custom controller named MyController?

ANSWER FEEDBACK

A. PUBLIC MYCONTROLLER(LIST<SOBJECT>
Incorrect. This is the structure of a controller
OBJECTS){ ACCOUNTS =
extension, not a custom controller.
(LIST<ACCOUNT>)OBJECTS;}

Correct. To create a constructor for a custom


B. PUBLIC MYCONTROLLER(){ ACCOUNT = NEW
controller, the constructor cannot have a
ACCOUNT(); }
parameter.

C. PUBLIC MYCONTROLLER(SOBJECT OBJ){ Incorrect. A custom controller constructor does not


ACCOUNT = (ACCOUNT) OBJ; } have a parameter.

D. PUBLIC MYCONTROLLER(LIST<SOBJECT>
Incorrect. A custom controller constructor does not
OBJECTS){ ACCOUNTS =
have a parameter.
(LIST<ACCOUNT>)OBJECTS; }

13
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 2
A developer uses a before insert trigger on the Lead object to fetch the Territory__c object, where the
Territory__c.PostalCode__c matches the Lead.PostalCode. The code fails when the developer uses the Apex
Data Loader to insert 10,000 lead records. The developer has the following code block.

01 for(Lead l : Trigger.new){
02 if(l.PostalCode != null){
03 List<Territory__c> terrList = [SELECT Id FROM Territory__c WHERE
PostalCode__c = :l.PostalCode];
04 if(terrList.size() > 0){
05 l.Territory__c = terrList[0].Id;
06 }
07 }
08 }

Which line of code is causing the code block to fail?

ANSWER FEEDBACK

A. 01: TRIGGER.NEW IS NOT VALID IN A Incorrect. You can use trigger.new in a before insert
BEFORE INSERT TRIGGER. trigger.

B. 02: A NULLPOINTER EXCEPTION IS Incorrect. This will not happen because in line 2, the code
THROWN IF POSTALCODE IS NULL. is making sure PostalCode is not null.

Correct. This will fail on the record number 201


C. 03: A SOQL QUERY IS LOCATED INSIDE
because the limit of SOQL queries is 200. Best
OF THE FOR LOOP CODE.
practice is to avoid SOQL queries inside for loops.

D. 05: THE LEAD IN A BEFORE INSERT Incorrect. The lead fields in a before insert trigger can be
TRIGGER CANNOT BE UPDATED. updated.

14
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 3
A developer needs to automatically populate the ReportsTo field in a contact record based on the values of the
related Account and Department fields in the contact record. Which two trigger types should the developer
create? (Select two answers.)

ANSWER FEEDBACK

Correct. The developer should use a


before update trigger. That way there
is no need for an extra DML
A. BEFORE UPDATE
statement. It is good practice to use
before triggers to validate updated
records before they are saved.

Correct. The developer should use a


before insert trigger. That way there
is no need for an extra DML
B. BEFORE INSERT
statement. It is good practice to use
before triggers to validate records
before they are created.

Incorrect. After triggers should not be


used to update fields on the record
being created. After triggers are used to
C. AFTER INSERT
access field values that are set by the
system and to affect changes in other
records.

Incorrect. After triggers should not be


used to update fields on the record
being updated. After triggers are used
D. AFTER UPDATE
to access field values that are set by the
system and to affect changes in other
records.

15
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 4
A hierarchy custom setting stores a specific URL for each profile in Salesforce. Which statement can a
developer use to retrieve the correct URL for the current user’s profile and display this on a Visualforce Page?

ANSWER FEEDBACK

A. {!$SETUP.URL_SETTINGS__C.URL__C} Correct. A specific profile should get a


specific record type. So, simply getting a
record type Id will not work. We need to
know what each profile should get.
Hierarchy custom settings support unique
values per profile.

B. Incorrect. There is no need to specify the


{!$SETUP.URL_SETTINGS__C.INSTANCE[PROFILE.I profile. Correct syntax is
D].URL__C} {!$Setup.CustomSettingName__c.CustomField
Name__c}.

C. Incorrect. There is no need to specify the


{!$SETUP.URL_SETTINGS__C[PROFILE.ID].URL__C profile. Correct syntax is
} {!$Setup.CustomSettingName__c.CustomField
Name__c}.

D. Incorrect. There is no need to specify the


{!$SETUP.URL_SETTINGS__C[$PROFILE.ID].URL__ profile. Correct syntax is
C} {!$Setup.CustomSettingName__c.CustomField
Name__c}.

16
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 5
In which order does Salesforce execute events upon saving a record?

ANSWER FEEDBACK

A. VALIDATION RULES; BEFORE TRIGGERS; VALIDATION Correct.


RULES; AFTER TRIGGERS; ASSIGNMENT RULES;
WORKFLOW RULES; COMMIT Runs system validation check.

Executes all before triggers.

Runs most system validation steps


again, such as verifying that all
required fields have a non-null value,
and runs any user-defined validation
rules. The only system validation that
Salesforce doesn't run a second time
(when the request comes from a
standard UI edit page) is the
enforcement of layout-specific rules.

Executes duplicate rules. If the


duplicate rule identifies the record as a
duplicate and uses the block action,
the record is not saved and no further
steps, such as after triggers and
workflow rules, are taken.

Saves the record to the database, but


doesn't commit yet.

Executes all after triggers.

Executes assignment rules.

Executes auto-response rules.

Executes workflow rules.

If there are workflow field updates,


updates the record again.

If the record was updated with


workflow field updates, fires before
update triggers and after update
triggers one more time (and only one
more time), in addition to standard
validations. Custom validation rules,
duplicate rules, and escalation rules
are not run again.

17
Platform Developer I Certification Prep: Process Automation and Logic

B. BEFORE TRIGGERS; VALIDATION RULES; AFTER Inorrect. Once the after triggers are
TRIGGERS; WORKFLOW RULES; ASSIGNMENT RULES; executed, the assignment rules
COMMIT execute.

C. VALIDATION RULES; BEFORE TRIGGERS; AFTER Incorrect. Once the after triggers are
TRIGGERS; WORKFLOW RULES; ASSIGNMENT RULES; executed, the assignment rules
COMMIT execute.

D. BEFORE TRIGGERS; VALIDATION RULES; ASSIGNMENT Incorrect. There are validation rules that
RULES; WORKFLOW RULES; AFTER TRIGGERS; COMMIT happen before the before triggers
execute that are system level
validations, this includes page level
validations and field length checks.
Once the after triggers are executed,
the assignment rules execute.

18
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 6
How can a developer determine if a CustomObject__c record has been manually shared with the current user
in Apex?

ANSWER FEEDBACK

A. BY CALLING THE PROFILE SETTINGS OF THE CURRENT Incorrect. Profile does not provide
USER record sharing information.

Correct. To access sharing


programmatically, you must use the
share object associated with the
standard or custom object for which
B. BY QUERYING CUSTOMOBJECT__SHARE you want to share. All custom object
sharing objects are named
MyCustomObject__Share, where
MyCustomObject is the name of the
custom object.

C. BY CALLING THE ISSHARED() METHOD FOR THE Incorrect. The isShared method does
RECORD not exist for this functionality.

Incorrect. Role hierarchy alone does not


D. BY QUERYING THE ROLE HIERARCHY
give enough information on sharing.

19
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 7
A developer creates a workflow rule declaratively that changes the value of a field on an object. An Apex after
update trigger exists for the object. What happens when a user updates a record?

ANSWER FEEDBACK

Correct. After the workflow rule, the


A. THE APEX TRIGGER IS FIRED MORE THAN ONCE.
trigger is executed again.

Incorrect. The workflow rule is only


B. THE WORKFLOW RULE IS FIRED MORE THAN ONCE.
executed once.

Incorrect. Changes are made, since the


C. NO CHANGES ARE MADE TO THE DATA. workflow rule is executed and then the
trigger.

D. BOTH THE APEX TRIGGER AND WORKFLOW RULE ARE Incorrect. The workflow rule is fired
FIRED ONLY ONCE. once, but the trigger is executed twice.

20
Platform Developer I Certification Prep: Process Automation and Logic

Scenario 8
A developer wants to display all of the available record types for a Case object. The developer also wants to
display the picklist values for the Case.Status field. The Case object and the Case.Status field are on a custom
Visualforce page.

Which two actions should the developer perform to get the record types and picklist values in the controller?
(Select two answers.)

ANSWER FEEDBACK

A. USE SCHEMA.RECORDTYPEINFO RETURNED BY Correct. A RecordTypeInfo object is


CASE.SOBJECTTYPE.GETDESCRIBE().GETRECORDTY returned from the sObject describe result
PEINFOS(). using the getRecordTypeInfos method.

Incorrect. This is unnecessary and very


B. USE SOQL TO QUERY CASE RECORDS IN THE ORG inefficient since this information can be
TO GET ALL THE RECORDTYPE VALUES AVAILABLE gathered using
FOR CASE. Case.SObjectType.getDescribe().getRecordTy
peInfos().

C. USE SCHEMA.PICKLISTENTRY RETURNED BY


Correct. getPicklistValues() returns a list of
CASE.STATUS.GETDESCRIBE().GETPICKLISTVALUES(
PicklistEntry objects.
).

Incorrect. This is unnecessary and very


D. USE SOQL TO QUERY CASE RECORDS IN THE ORG
inefficient since this information can be
TO GET ALL VALUES FOR THE STATUS PICKLIST
gathered using
FIELD.
Case.Status.getDescribe().getPicklistValues().

21
Platform Developer I Certification Prep: Process Automation and Logic

Exam Topic Flashcards


The flashcards in this unit cover Apex classes and triggers. Use these interactive flashcards to brush up on
some of the key topics you’ll find on this part of the exam.

Read the question or term on each card, then click the card to reveal the correct answer. Click the right-facing
arrow to move to the next card, and the left-facing arrow to return to the previous card.

Question/Term Answer/Definition
A developer writes a before insert
trigger. Which context variable
can the developer use to access The Trigger.new context variable
the incoming records in the
trigger body?

Which method can a developer


use to determine, from the
DescribeSObjectResult, if the The isCreatable() method
current user will be able to create
records for an object in Apex?

1. Before triggers are executed.

2. System validation steps are run again


In the execution order of triggers, and user-defined validation rules are
what three steps happen after the checked.
before triggers execute, and
3. Executes duplicate rules.
before the after triggers
execute? 4. The record is saved to the database but
doesn’t commit yet.

5. Executes all after triggers.

True or False: Workflows support


False
publishing platform events.

22
Platform Developer I Certification Prep: Process Automation and Logic

Related Badges

Looking for more information? Explore these related badges.

Badge Content Type

Module

Lightning Flow

Module

Apex Triggers

Superbadge

Apex Specialist

Congratulations! You’ve studied up on the process automation and logic section of the Platform Developer I
certification exam.

23

You might also like