Study your flashcards anywhere!

Download the official Cram app for free >

  • Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key


Play button


Play button




Click to flip

122 Cards in this Set

  • Front
  • Back

Apex Triggers- Order of execution: In what order are automation rules and Apex triggers processed (First 8)?

1. Old record loaded from database (or initialized for new inserts)

2. New record values overwrite old values

3. System Validation Rules (If inserting Opportunity Products, Custom Validation Rules will also fire in addition to System Validation Rules)

4. All Apex before triggers (EE / UE only)

5. Custom Validation Rules

6. Record saved to database (but not committed)

7. Record reloaded from database

8. All Apex after triggers (EE / UE only)

Apex Triggers- Order of execution: In what order are automation rules and Apex triggers processed (Next 8)?

1. Assignment rules

2. Auto-response rules

3. Workflow rules

4. Processes

5. Escalation rules

6. Parent Rollup Summary Formula value updated (if present)

7. Database commit

8. Post-commit logic (sending email)

Apex Triggers- Order of execution: In what order are automation rules and Apex triggers processed (All 16)

1st 8, Next 8

Triggers- How do you prevent a record from being saved?

To prevent saving records in a trigger, call the addError() method on the sObject in question. The addError() method throws a fatal error inside a trigger.

Trigger- How should callouts be implemented?

Call a class method that executes asynchronously. Such a method is called a future method and is annotated with @future(callout=true).

There are only two things that you can do with workflow that you can’t do with processes. What are they?

Configure actions to be executed at different times.With a process, you can configure actions to be performed at a later time, but all of those actions are performed at the same time. If you need multiple “later”s, use workflow. For example, use multiple time triggers in a workflow rule to send an account manager email reminders one month, two weeks, one week, and three days before the related contract expires.

Send outbound messages without code. However, you can work around this limitation by calling Apex code from a process

When should you use Visual Flow?

If the process is too complicated for the Process Builder or requires more advanced functionality.

Use complex branching logic

Sort through, iterate over, and operate on several records

Describe the differences between SOSL and SOQL

Use SOQL to retrieve records for a single object.

Use SOSL to search fields across multiple objects. SOSL queries can search most text fields on an object.

SOSL- returns a list of a list of sobjects

List>(each list contains the searchresults for a particular sObject)

SOQL-returns a list of sObjects, a single sObject, or an Integer for count method queries.

What are some of the language constructs that Apex supports:

Classes, interfaces, properties, and collections (including arrays).

Object and array notation.

Expressions, variables, and constants.

Conditional statements (if-then-else) and control flow statements (for loops and while loops).

What data structures does Apex support?

A primitive, such as an Integer, Double, Long, Date, Datetime, String, ID, Boolean, among others.

An sObject, either as a generic sObject or as a specific sObject, such as an Account, Contact, or MyCustomObject__c (you’ll learn more about sObjects in a later unit.)

A collection, including: A list (or array) of primitives, sObjects, user defined objects, objects created from Apex classes, or collections A set of primitives A map from a primitive to a primitive, sObject, or collection A typed list of values, also known as an enum User-defined Apex classes System-supplied Apex classes

What are two things that you can do with workflows that you cannot do with process builder?

1. Configure actions to be executed at different times.

2. Send outbound messages without code.

Which automation tool is best fit for creating wizards?

Ans- Visual flow

When should you use an Apex trigger vs work flow?

. One of the common reason to write an apex trigger is to update children of an object. Salesforce Workflow rules can perform an update on parent record but not to child records. workflow rules also doesn’t support few standard to standard cross object field update.

Apex trigger for complex validation rules.

Describe the Apex primitive data types

String: Strings are set of characters and are enclosed in single quotes. They store text values such as a name or an address.

Boolean: Boolean values hold true or false values and you can use them to test whether a certain condition is true or false.

Time, Date and Datetime: Variables declared with any of these data types hold time, date, or time and date values combined.

Integer, Long, Double and Decimal: Variables declared with any of these data types hold numeric values.

Null variables: Variables that you don’t assign values to.Enum: An enumeration of contant values.

Describe the data types available in Apex:

1. Primitives

2. sObject

3. Collection

4. enums

5. User defined objects

6. System defined

7. Null

What is an sObject?

The term sObject refers to any object that can be stored in the platform database.

*Custom labels are not standard sObjects.

Describe the Collection types

Lists-A list is an ordered collection of elements that are distinguished by their indices. List elements can be of any data type

Maps- A map is a collection of key-value pairs where each unique key maps to a single value.

Sets- A set is an unordered collection of elements that do not contain any duplicates. A set can contain up to four levels of nested collections inside it, that is, up to five levels overall.

Describe the syntax for a set

Set s1 = new Set{'a', 'b + c'}; // Defines a new set with two elements

Set s2 = new Set(s1); // Defines a new set that contains the

Declare an enum:

public enum Season {WINTER, SPRING, SUMMER, FALL}

What is an Apex constant?

Apex constants are variables whose values don’t change after being initialized once.

How are constants declared?

Constants can be defined using the final keyword:

static final Integer PRIVATE_INT_CONST = 200; static final Integer PRIVATE_INT_CONST2;

How do you create comments in Apex

// comment

/* comment */

Why should you use SOQL for loop vs List and for loop?

The reason why this happens is because of the limit on heap size. To resolve, use a SOQL query for loop instead, since it can process multiple batches of records through the use of internal calls toqueryandqueryMore

In SOQL for loop, what is the batch size?


What is the ideal way of writing a bulkified SOQL for loop?

for (Merchandise__c[] tmp : [SELECT Id FROM Merchandise__c]) { // Perform some actions on the single merchandise record.}


for (Merchandise__c tmp : [SELECT Id FROM Merchandise__c]) { // Perform some actions on the single merchandise record.}

How is a test method class and method declared?

//can be private or public

@isTest private class myTest(){

@isTest static void myTestMethod(){

//test logic



Classes defined with the isTest annotation don't count against your organization limit of 3 MB for allApex code. True or False?


What are some of the limitations of test classes?

1. No email

2. Test methods can’t be used to test Web service callouts. - use mock callouts

3. If a test class contains a static member variable, and the variable’s value is changed in a testSetup or test method, the new value isn’t preserved.

Test classes cannot access private member variables (in the class being tested). How can a test class access the private member variables?

Modify the private member variable with the "@TestVisible" annotation...ex,

@TestVisible private Integer recordNumber = 0;

This also works with private methods

Apex test data is transient and isn’t committed to the database. True or False


By default, existing organization data is visible to test methods. True or False


What is the syntax for granting data access to a test class?


note...Test code saved using Salesforce API version 23.0 or earlier continues to have access to all data in the organization and its data access is unchanged.

What other technique can be used to load test data?

Test.loadData method, you can populate data in your test methods without having to write many lines of code. ex,

Test.loadData(Account.sObjectType, 'testAccounts');

This will return a list of accounts.

To create test records once and then access them in every test method in the test class, what construct must be used?

@testSetup static void methodName() {}

* this will be executed first:

How can you run a test using a different user context?

Use the runAs method to test your application in different user contexts.

Which type of sandbox is best suited for testing and why?

Full Copy- because it mimics the metadata and data in production and helps reduce differences in code coverage numbers between the two environments.

You are writing a test method that could potentially exceed a DML limit. How can you mitigate an exception?

The test method contains the Test.startTest() and Test.stopTest() method pair, which delimits a block of code that gets a fresh set of governor limits.

How do you write unit test for Apex controller?

you can set query parameters that can then be used in the tests.

ApexPages.currentPage().getParameters().put('qp', 'yyyy');

Describe the differences between invoking Apex in execute anonymous vs. unit test

Unit test executes in system mode and any changes made to records are not visible out of its test execution context where with anonymous block any changes performed to data are visible after its execution is successful. Code written in anonymous block is not stored as metadata in salesforce org and user permissions are enforced during execution.

In what two ways can an Apex programmer get information about an object?

You can describe sObjects either by using tokens or the describeSObjects Schema method.

Apex supports the following five types of procedural loops:

do {statement} while (Boolean_condition);

• while (Boolean_condition) statement;

• for (initialization; Boolean_exit_condition; increment) statement;

• for (variable : array_or_set) statement;

• for (variable : [inline_soql_query]) statement;

Describe some of the basic string methods:



.mid(index, length)

Describe a ternary operation? syntax...

If x, a Boolean, is true, then the result is y; otherwise it isz.

x ? y : z

How do you declare a new instance of Date, DateTime, or Time?




What are the Apex DML methods?

* Insert

* Update

* Delete

* UnDelete

* Upsert - Inserts/updates based on Salesforce Id or existing external IDprescribedbrO79

What are the Database Class methods?






When to Use DML Statements vs Database Class methods?

Use DML statements if you want any error that occurs during bulk DML processing to be thrown as an Apex exception that immediately interrupts control flow (by using try. . .catch blocks). This behavior is similar to the way exceptions are handled in most database procedural languages.

Use Database class methods if you want to allow partial success of a bulk DML operation—if a record fails, the remainder of the DML operation can still succeed. Your application can then inspect the rejected records and possibly retry the operation. When using this form, you can write code that never throws DML exception errors. Instead, your code can use the appropriate results array to judge success or failure. Note that Database methods also include a syntax that supports thrown exceptions, similar to DML statements.

Declare an array of strings:

String[] fname = {'Bob','John', 'Juan'}

Which method would you use to add an element to an array?


Which method would you use to empty an array?


How could you get the size of an array?


How could you remove an element of an array?

a.remove(integer index);

Describe the advanced Apex data types:




When should a List be used?

List- when an ordered list is required. You’ll typically use a list whenever you want to store a set of values that can be accessed with an index.

When should a set be used?

Set- Use a set when you don’t need to keep track of the order of the elements in the collection, and when the elements are unique and don’t have to be sorted.

When should a map be used?

Use a map when you want to store values that are to be referenced through a key. For example, using a map you can store a list of addresses that correspond to employee IDs.

Declare a set


Declare a map

finish this

Declare a boolean

Boolean isReady = false;

Syntax for logical AND, OR

&& ||

Describe four popular string methods:

The endsWith method returns true because the string ends with the same string as that in the argument.

• The length method returns the length of the string.

• The substring method produces a new string starting from the character specified in the first index argument, counting fromzero, through the second argument.

• The replaceAll method replaces each substring that matches a regular expression with the specified replacement. In this case,we match for text within exclamation points, and replace that text with what was matched (the $1).

When should the String data type be used?

Use the String data type when you need to store text values, such as a name or an address. Strings are sets of characters enclosed insingle quotes.

Declare a new Date that return Oct 14 1973

Date bday = Date.newInstance(1973, 10, 14);

Declare a new Time var that return 5:30PM

Time goHome = Time.newInstance(16,30,0,0);

Initialize a DateTime variable with the current Date and Time:

DateTime rightNow = DateTime.Now();

Initialize a Date variable with today's date:

Date currDate = Date.Today();

Initialize a Time variable with the current time

Time currTime = DateTime.Now().Time();

How do you cast '10' to an integer

Integer num = Integer.valuedof('10');

When should you use an enum?

Use enumerations (enums) to specify a set of constants.

Declare an enum and use an instance:

public enum Season {WINTER, SPRING, SUMMER, FALL};

Season s = Season.SUMMER;

if (s == Season.SUMMER) {...}

Give an example of a system Enum:


What are two ways in which you can modify an element in a list?

// using the array notation

myList[0] = 15;

// or using the set method


When should a set be used?

Use a set when you don’t need to keep track of theorder of the elements in the collection, and when the elements are unique and don’t have to be sorted.

Declare a set with three string characters:

Set s = new Set{'a','b','c'};

What is the out come of the following operation:

Set s = new Set{'a','b','c'};


Nothing, duplicates cannot be inserted into the set

What is a Map?

Maps are collections of key-value pairs, where the keys are of primitive data types.

When should a Map be used?

Use a map when you want to store values that are tobe referenced through a key. For example, using a map you can store a list of addresses that correspond to employee IDs.

Create a Map of employee name's and addresses:

Map employeeAddresses = new Map();employeeAddresses.put (1, '123 Sunny Drive, San Francisco, CA');

employeeAddresses.put (2, '456 Dark Drive, San Francisco, CA');

Which method is used to get a value from a Map

.get(index name);

Which method is used to add to a Map?

.put(index name, value);

What is a Class?

Classes are templates from which you can create objects

What do private modifiers do?

The private modifier restricts access to a class, or a class method or member variable contained in a class, so thatthey aren’t available to other classes.

What is an interface?

Interfaces: Interfaces are named sets of method signatures that don’t contain any implementation.

What a Class properties?

Properties: Properties allow controlled read and write access to class member variables.

What is an interface?

An interface is a named set of method signatures (the return and parameter definitions), but without any implementation.

What is the benefit of an interface?

You can have different implementations of a method based on your specific application.

Declare an interface with one method:

public interface KitchenUtility {

String getModelNumber();


Now implement the interface

public class Toaster implements KitchenUtility {private String modelNumber;

public String getModelNumber() {

...method implementation

return someString;


Provide an example of a short hand syntax lets you define a variable and code that should run whenthe variable is accessed or retrieved:

public Integer ecoRating {

get { return ecoRating; }

set { ecoRating = value; if (ecoRating < 0) ecoRating =0; }


Apex code in classes (and triggers) runs in which context?

System context

When Apex executes, Object and field level security settings are enforced ( True or False)


Apex- A requirement is given that an Apex class must enforce sharing permission of the currently logged on user. What key word enables this?

with sharing

If an sObject is related to another by a master-detail or lookup relationship, how can you query the parent sObject field?

SELECT RelationshipName.Field FROM sObjectName WHERE Where_Condition [...]

SOQL-How can you fetch child sObjects?

specify a nested query that retrieves all request child sObjects and their fields as follows:

[SELECT Id, Name, (SELECT Units_Sold__c FROM Line_Items__r ]

Create a query that accesses the child objects and assigns to a list-

Invoice_Statement__c inv = [SELECT Id, Name, (SELECT Units_Sold__c FROM Line_Items__r)FROM Invoice_Statement__cWHERE Name='INV-0000'];

// Access child records.

List = inv.Line_Items__r;

What is the most efficient way of implementing a SOQL for loop?

Use a list variable:

for (Merchandise__c[] tmp : [SELECT Id FROM Merchandise__c]) {

// Perform some actions on the single merchandise record.


What happens to deleted records?

They go to the recyble bin for 15 days.

In Apex, how can you undelete a record(s)?

Invoice_Statement__c inv = [SELECT Status__cFROM Invoice_Statement__cWHERE Description__c='My new invoice'ALL ROWS];

undelete inv;

When should Database methods be used instead of DML?

When to Use DML Statements and Database DML StatementsTypically, you will want to use Database methods instead of DML statements if you want to allow partial success of a bulk DML operationby setting the opt_allOrNone argument to false.

What Apex construct can be used to handle exceptions?

try {// Perform some database operations that// might cause an exception.} catch(DmlException e)

{// DmlException handling code here.} catch(Exception e)

{// Generic exception handling code here.} finally {// Perform some clean up.}

The governor execution limits are per _____


What is wrong with this code:

for(Line_Item__c li : liList) {

if (li.Units_Sold__c > 10)

{li.Description__c = 'New description';}

// Not a good practice since governor limits might be hit.

update li;


DML update inside a for loop, if the list contains more than 150 elements, an exception will be thrown.

What are two ways in which a test method can be declared?

static testmethod void myTest()

{// Add test logic}

static @isTest void myTest()

{// Add test logic}

How many times can Test.startTest/Test.stopTest be called within a test method?

One time within a test method

SOQL for loops operate on batch size of___


What does a SOQL for loop help avoid?

the heap size limit of 6 MB

How are Apex classes scheduled?

write an Apex class that implements the Schedulable interface, and then schedule it for executionon a specific schedule.

When should a developer use Apex?

Create Web services.

• Create email services.

• Perform complex validation over multiple objects.

• Create complex business processes that are not supported by workflow.

• Create custom transactional logic (logic that occurs over the entire transaction, not just with a single record or object).

• Attach custom logic to another operation, such as saving a record, so that it occurs whenever the operation is executed, regardlessof whether it originates in the user interface, a Visualforce page, or from SOAP API.

What cannot be done with Apex?

Render elements in the user interface other than error messages

• Change standard functionality—Apex can only prevent the functionality from happening, or add additional functionality

• Create temporary files

• Spawn threads

– Test methods and test classes are not counted as part of Apex code coverage- True or False


All primitive data types are passed by reference- True or False

False, by value

What are the Apex primitive data types

1. Blob

2. Date

3. Date/Time

4. Time

5. String

6. Integer

7. Decimal

8. Double

9. ID

10. Long

11. Object

7. Boolean

What are the two loop control structures?

* break; exits the entire loop

* continue; skips to the next iteration of the loop

Which Apex class could be used to detect and handle exceptions related to limits?

Limits Class

How is the Limits class declared?


How could you identify the total # of DML limits used by your Apex code?


How could you identify the DML limits available to your code?


Which method would you use to get the picklist values?



Using Apex, how could you identify if an object is searchable, can be queried or updated by a specific user?

Call the DescribeSObjectResult class and use:



isSearchable() the current user.

Using Apex how could you identify if the current user can view a specific field?

Using DescribeSObjectResult and isAccessible();

.getDescribe() returns what type of object?


Schema.getGlobalDescribe().get('string object name') returns what type of object?

sObjectType -- an object token