PD1 2022

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What can be used to isolate a static HTML file on a separate domain?

$IFrameResource., where 'resource_name' is the name of the static resource

What namespace is used by Lighting Components that exist in two versions (Aura Component and Lightning Web Component)?

'lighting' namespace

What suffix is used by Lightning Components?

.cmp suffix

How do you find the size of a list variable?

.size()

How many controllers can a VF page have?

1

Let Flows Execute Apex Actions

1. @InvocableMethod annotation 2. Process.Plugin interface.

What are two publish behaviors for platform events?

1. A platform event message can be published immediately by choosing 'Publish Immediately' 2. Only after a transaction commits successfully by choosing 'Publish AfterCommit'

A developer creates a method in an Apex class and needs to ensure that errors are handled properly. What would the developer use?

1. A try/catch construct 2. .addError() 3. A custom exception

Additional Process Considerations

1. One process per object 2. Combine actions 3. Avoid infinite loops

VF pages and Apex variables

1. Primitive data types, such as Strings and Integers, are passed by value 2. Non-primitive data types, such as Lists or sObjects, are passed by reference

Should You Use DML Statements or Database Methods?

1. 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. 2. 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.

Lightning Component Framework - 2

4. Event Driven: It utilizes event-driven architecture. Components are capable of listening to application and component events and responding accordingly 5. Environments: Applications and components built using the Lightning Component framework run in Lightning Experience, Salesforce Mobile App, and Communities 6. Modular: Lightning components are modular where a component may contain another component. An Aura component may contain a Lightning web component, but the inverse is not allowed. 7. Responsive: The Lightning Component framework exercises relative sizing which enables images, media, and other elements to scale flexibly. Custom styling can also be implemented easily.

Flow - Limits Per Transaction - 2

4. Total number of records processed as a result of DML statements: 10,000; You can only modify a maximum of 10,000 records. 5. Maximum CPU time on the Salesforce servers: 10,000 milliseconds; CPU time is the amount of time that the servers use to process your solution. The maximum is 10,000 milliseconds (10 seconds). 6. Total number of duplicate updates allowed in one batch: 12; You can only update the same record a maximum of 12 times.

The maximum number of records that can be returned in the Database.QueryLocator object is ___.

50 Million

What can be used to create tables with custom styles in VF?

<apex:dataTable>, <apex:dataList>, <apex:repeat>

Which component can be used to display the detailed page of an object in a VF page?

<apex:detail>

How can you display an external website in an inline frame with a VF page?

<apex:iframe>

Which component can be used to display individual fields on a record in a VF page?

<apex:outputField>

Which code displays the content of Visualforce page as PDF?

<apex:page renderAs="pdf">

How do you create a simple VF form to create an account record?

<apex:page standardController="Account"> <apex:form > <apex:pageBlock > <apex:pageMessages /> <apex:pageBlockSection > <apex:inputField value="{! account.name}"/> <apex:commandButton action="{! save}" value="Save!"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> pageBlock adds the field labels

What is the syntax for adding a table in VF using a standard controller?

<apex:pageBlockTable value="{! account.contacts}" var="item"> </apex:pageBlockTable> <apex:column value="{! item.name}"/> You can think of this component as doing the following: it takes a look at its value attribute, and retrieves the list of records that it finds there. In this case, it retrieves the contacts field that represents the list of Contact records associated with the current Account record. Then, for each individual Contact record, it assigns it to a variable called item. The <apex:column> component creates a new column within the table. It adds a table header based on the name of the field, and also outputs the values for that field in the rows of the table, one row per record

Which iteration component can be used to generate a table of data within platform styling?

<apex:pageBlockTable>

When using a standard VF controller, how can you show a standard related list?

<apex:relatedList list="Cases" />

Which component can be used to allow users to filter records on a VF page?

<apex:selectlist>

Which tag is used to add CSS to VF pages?

<apex:stylesheet>

Which tag can be used in an Aura component to handle an event?

<aura:handler>

Which tag can be used in an Aura component to register to an event?

<aura:registerEvent>

How can you fire a custom event so that it is exposed to other components on a Lightning Page?

<event> and <schema> sub-tabs are added within two <targetConfig> sub-tabs

Which tag can be used to reference a JavaScript library uploaded as a static resource in .cmp markup?

<ltng:require>

Enforcing CRUD in Apex

<sObject>.sObjectType.getDescribe() - isCreateable() - isAccessible() - isUpdateable() - isDeletable()

Data Access Control - Lightning Components

@AuraEnabled Apex classes used by Aura components or Lightning web components that do not specify "with sharing" or "without sharing" will default to "with sharing" to ensure that Lightning components are secure by default Key point: classes for LCs default to "with sharing"; those that are aura-enabled

Which annotation should be used for an Apex method that needs to be invoked by a process?

@InvocableMethod

What is the correct definition of the Apex method?

@InvocableMethodglobal static List<List<Recommendation>> getLevel(List<ContactWrapper> input) { /*implementation*/ }

In test Apex classes, what is the difference between @isTest and @testSetup?

@isTest - used here to define the Apex class as a test class or used here to define the method as a test method; test methods must be void and not return any value. Not all methods in a test class has to be test methods. @testSetup - defines the method as a method used for creating test data.

Choice Set Components

A Collection Choice Set, Record Choice Set, or Picklist Choice Set resource can be used to display options in a choice set component such as a checkbox group, radio button, or picklist.

Interactions Between Apex and Lightning Web Components

A Lightning web component can wire a function or property to call an Apex method

Visualforce Controllers

A Visualforce page uses either a standard or custom controller, and then an extension class can be added to extend its functionality.

Component CSS file

A cascading style sheet can be included in a Lightning web component to implement CSS styling

Apex Classes

A class is a template or blueprint from which objects in Apex are created. An object is an instance of a class. The technical use cases in Salesforce below require the creation of an Apex class.

What is a test suite?

A collection of Apex test classes that is run together

Controller Extension

A controller extension is an Apex class which can be used to extend a standard or custom controller.

A cross-object formula can reference how many levels?

A cross-object formula can reference fields from master/parent objects are up to 10 relationships away.

Creating a Custom Screen Component

A custom screen component can be created for a flow screen in Flow Builder using a Lightning web component. The lightning__FlowScreen target is added to make the component usable in the flow screen

SOQL Date Literals

A date literal in SOQL is an expression that represents a relative range of time, such as yesterday, tomorrow, five weeks from now, or three quarters from today. Here are some example date literals. Examples: WHERE CreatedDate = YESTERDAY WHERE Birthdate = NEXT_WEEK WHERE CloseDate > LAST_90_DAYS WHERE TargetDate__c > NEXT_N_MONTHS:6

Debug Log

A debug log can record database operations, system processes, and errors that occur when executing a transaction or running unit tests. Debug logs can contain information about: 1. Database changes 2. HTTP callouts 3. Apex errors 4. Resources used by Apex 5. Automated workflow processes, such as: a. Workflow rules b. Assignment rules c. Approval processes d. Validation rules Note: The debug log does not include information from actions triggered by time-based workflows.

Invoking a Flow from Apex

A flow can be invoked from Apex code.

Debugging flow as another user

A flow can be run as another user while debugging in a sandbox org. To enable this feature, one can select the 'Let admins debug flows as other users' checkbox in 'Process Automation Settings'. When debugging the flow, 'Run flow as another user' can be selected in the Debug options, and a user can be selected

Example of Starting a Flow from Apex Dynamically

A flow can be started from Apex code dynamically. In this example, an Apex method will launch a specific flow based on the flow name which is passed to it as a parameter

Starting a Flow from Apex Dynamically

A flow interview can also be created dynamically at run-time using a Flow.Interview method.

Limit Queries and Results

A limit exception is thrown when a transaction exceeds the number of allowed database queries. Also, queries should be selective so as not to exceed the governor limit of the number of records retrieved.

Trigger.newMap.KeySet()

A method used on maps that returns all the keys of the map. Since the key in the map above is the record ID, you are returned a set of all IDs in your map.

Switch Statements

A more efficient alternative to an if-else statement is a switch statement. A switch statement specifies a set of values and tests an expression to determine whether it matches one of those values. Here is how it looks: switch on expression { when value1 { //single value //code block 1 } when value2, value3 { //multiple values //code block 2 } }

Namespace

A namespace is a 1-15 character alphanumeric identifier that distinguishes your package and its contents from other packages in your customer's org. A namespace is assigned to a package at the time that it's created, and can't be changed.

Schema Namespace Classes - 1

A number of important classes are available in the Schema namespace for accessing metadata information

Polymorphic Fields and Apex

A polymorphic relationship is a relationship field where the referenced object can be one of different sObject types. For example, the Who field of a task can be a contact or a lead. Or, the What field of an event can be an account or an opportunity. 1. Query Options: There are two options for querying polymorphic fields in Apex and get results based on the referenced object type. One approach is using theType qualifier. The other approach is using the TYPEOF clause. 2. Using Type Qualifier: The below shows using the Type filter to retrieve records based on the type of the referenced object in the polymorphic field. List<Task> tasks = [SELECT Id, Description FROM Task WHERE Who.Type IN ('Contact', 'Lead')];

Which operations can be performed on external objects from a process?

A process can be created to look up, create, or update external objects.

Subscribing to Platform Events - 1

A process can be used to subscribe to a platform event message.

Test Data Factory

A public test utility class can be used to set up test data used by test methods

Dynamic SOQL Query

A query string can be constructed dynamically and executed at run time using the Database class query method.

Queueable Apex Class - 2

A queueable Apex class must implement a method called execute such as the following example:

With record-triggered flows, when can they run?

A record is created A record is updated A record is created or updated A record is deleted

Record-Triggered Flows

A record-triggered flow can be set to automatically run when it a record is created, updated, deleted.

Sorting Record-Triggered Flows

A record-triggered flow provides a Trigger Order property for specifying when the current flow should run when there are multiple flows for the same object and trigger type (before-save or after-save).

Schedulable Apex Class

A schedulable Apex class must implement a method called execute such as the following example

Scheduled Paths in Record-Triggered Flows

A scheduled path can be defined to execute a part of the flow at a dynamically scheduled time. 1. Scheduled Time: the scheduled time can be based on when the record is created or updated or on a field value on the record. 2. System Context: scheduled paths run in system context and can access and modify all data. 3. Monitoring: the Time-Based Workflow page in Setup can be used to monitor the scheduled paths that are queued to run.

One Trigger For All Trigger Events

A single Apex trigger can be created to handle all types of events for one object. The trigger below handles multiple DML events and uses a trigger handler class to process the records.

One Trigger Per Object

A single Apex trigger is all that is needed essentially for each object

Assigning SOQL Query Results

A single sObject can be used to store the result of a SOQL query. However, a System.QueryException will be thrown when the query fails to exactly return a single record. Note: Query results must return at least one record in this specific example since there is a clause of LIMIT 1

Apex Transactions

A single unit of operations in Apex is referred to as an Apex transaction

Standard List Controller

A standard list controller is used by setting the standardController attribute on the <apex:page> component and the recordSetVar attribute on the same component

Stateless vs. Stateful System

A stateless system sends a request to the server and relays the response (or the state) back without storing any information. On the other hand, stateful systems expect a response, track information, and resend the request if no response is received.

Static block

A static block can be used to apply values to static variables; static values can be modified later only if they are not final variables.

Trigger Exceptions

A subset of the records being processed can be marked with the addError() method: 1. If the trigger was spawned by a DML statement in Apex, any one error results in the entire operation rolling back. However, the runtime engine still processes every record in the operation to compile a comprehensive list of errors. 2. If the trigger was spawned by a bulk DML call in the Lightning Platform API, the runtime engine sets aside the bad records and attempts to do a partial save of the records that did not generate errors.

Tokens

A token is a reference to an sObject or field and used to identify the sObject or field in scenarios where they are only determined during runtime. A token can be used to describe SObjects and fields.

Transaction Example

A transaction is a set of operations that is executed and evaluated as a single unit. Each event that occurs in a single transaction are bound by their associated governor limits.

Apex Transaction Entry Points

A transaction may be initiated from: Apex trigger Class method Anonymous code Web service Visualforce page Custom Lightning component Process Flow and others

Apex Transaction

A transaction, which is also known as an execution context, can be initiated from various sources in the Salesforce platform.

Switch Statement Values

A value in a when block can be one of the following

Add 6 months to a date field

ADDMONTHS(Contract_Start_Date__c, 6)

What keyword do you used in SOQL to include deleted records in the recycling bin?

ALL ROWS keyword

SOQL aggregate functions

AVG(), COUNT(), COUNT_DISTINCT(), MIN(),MAX(), and SUM().

What are the requirements for a class definition?

Access modifier, class keyword, and name of the class

Method - Access Modifier

Access modifiers such as public or protected can be added to the method definition, but it is optional

What are two ways to declare an Account object in Apex?

Account acc = new Account(); sObject objxyz = new Account();

Sample Apex code for merging accounts

Account masterAccount = [SELECT Id, Name FROM Account WHERE Name = 'Salesforce' LIMIT 1]; Account MergeAccount = [SELECT Id, Name FROM Account WHERE Name = 'Salesforce.com' LIMIT 1]; merge masterAccount MergeAccount;

Which method can be used in a custom controller to respond to user input on a VF page?

Action method

Modal Notifications

Alert, Confirm, and Prompt modules can be used by Lightning web components to replace the soon-to-be deprecated nativealert(), confirm(), and prompt() APIs of the window object

Which tests are by default for deployment to production?

All local testst

Invoking Apex from a Process

An Apex action is defined with an Action Name and Apex Class for adding Apex code functionality to a process.

Component SVG Icon

An SVG file can be added to customize the icon that represents the Lightning web component

What can prevent a VF page from using an anti-CSRF token?

An action handler in apex:page

What happens if the following code is written? List<Lead> standardFields = [SELECT Company,FIELDS(STANDARD) FROM LEAD LIMIT 1];

An error will be thrown when a specific field that is already included is explicitly added to query; Company is included in FIELDS(STANDARD)

What are some examples for Apex expressions?

An expression is a construct made up of variables, operators and/or method invocations, that evaluates to a single value. Expressions can be: 1. A literal 2. sObject 3. List 4. Set 5. Map 6. SOQL 7. SOSL query 8. Static or instance method invocation

Inline Visualforce Page

An inline Visualforce page is a Visualforce page that is embedded in page layouts of a standard or custom object: 1. Standard controller: The VF page should use the standard controller of the standard or custom object associated with the page layout in order for the page to be available in the page layout editor. 2. VF Pages Option: The VF page will not be available or appear as an option in the page layout editor if it does not use the standard controller for the object.

Interfaces

An interface is used to require a class to implement specific methods. 1. Interface keyword: The structure of an interface is similar to a class, but it uses the interface keyword and only contains method signatures. 2. Method signature: A method signature does not contain a body or access modifier and only consists of the name and any method parameter or return type. 3. Implements keyword: A method signature does not contain a body or access modifier and only consists of the name and any method parameter or return type.

What type of Apex can you call from process builder or flow?

An invocable Apex method can be created and invoked as an Apex action in a process or flow

Interactions Between Apex and Lightning Web Components

Apex methods can be invoked from a Lightning web component.

Access Modifiers of Apex Properties

Aura and Lightning web components respect the access modifiers defined on Apex properties of their Apex controllers

Schedulable Apex Class

Batch Apex can be scheduled by implementing an interface that enables it to be scheduled as an Apex job

Batch Apex Class

Batch Apex implements an interface which enables it to execute complex, long-running operations over small batches of thousands of records. 1. Interface Required: An Apex class that implements the Database.Batchable interface is required to use batch Apex. 2. Batch Apex Job: The Database.executeBatch method can be used to execute a batch Apex job. It requires two parameters: an instance of the batch Apex class and an optional scope (number of records to pass into the method).

What are the supported triggers

Before Insert Before Update Before Delete After Insert After Update After Delete After Undelete Note: there is no Before Undelete

Types of Flow - Field Service Mobile Flow

Build a flow for the Field Service mobile app.

How can CSS be added to a Lightning Component bundle?

By clicking on the STYLE button in the Developer Console sidebar

Which formula field function can be used to return the conversion rate to the corporate currency for a given currency ISO code?

CURRENCYRATE

What are some considerations when writing triggers?

Can process automation tools be used instead?, ensure the trigger is bulkified, one trigger per object and the execution context is understood

Which custom field types are support for platform events?

Checkbox, Date, Date/Time, Number, Text, and Text Area (Long)

Code Coverage Computation

Code Coverage Percentage, which is computed when running tests, uses the formula: CCP = (number of covered lines) / (number of covered lines + number of uncovered lines) The following are not counted and does not impact code coverage percentage: -Code comments -Class name definition -Lines that only contain brackets -System.debug statements

Querying multi-select picklists

Commas mean OR; e.g., AAA:BBB means AAA OR BBB Semicolons mean AND; e.g., AAA;BBB means AAA AND BBB

Which functions used in SOQL count as one query row toward governor limit for the total number of rows that can be retrieved?

Count() and Count(fieldName)

What can you do with schema builder?

Create Objects with Schema Builder Create Fields with Schema Builder Delete Custom Objects with Schema Builder You can delete the custom objects that you no longer need by using Schema Builder. Delete Custom Fields with Schema Builder

Types of Flow - User Provisioned Flow

Create a user account and link it to a third-party service or app.

Database Class Methods - Database Class Methods - SETSAVEPOINT

Creates a savepoint variable for restoring the database to that point using the rollbackmethod

DOM Events: Capture & Bubble

DOM events follow two consecutive propagation phases that developers can follow: 1. Capture (rarely used) 2. Bubble (widely used) Events first go down the DOM tree during the capture phase, then up during the bubble phase. The capture phase always executes before the bubble phase.

Related Field Values

Data from related records can be retrieved, and up to five levels of child-to-parent relationships and one level of parent-to-child relationships can be traversed

How can you run anonymous Apex?

Developer Console VS Code Via SOAP API call

What can be used to create a package for AppExchange distribution?

Developers can use a Partner Developer Edition to manage all the source code and a Developer Edition org to create a package and distribute it to AppExchange or Trialforce. Sandboxes cannot be used to publish apps on the AppExchange.

<apex:map>

Display an interactive, JavaScript-based map, complete with zooming, panning, and markers based on your Salesforce or other data. <apex:map> doesn't, by itself, display map markers, even for the center point. To display up to 100 markers, add child <apex:mapMarker> components. Note: Salesforce does not provide a JavaScript library for creating maps

When can you not use a standard VF controller?

Displaying the opportunities related to an account is possible using a Visualforce page that is bound to an Account standard controller. However, it is not possible to display the list of opportunity line items related to the opportunities of the account on the same Visualforce page

Use this loop when it needs to be executed at least once

Do-While loop

Dynamic Interactions

Dynamic Interactions enable Lightning web components to fire and expose custom events that other components on the same Lightning page can respond to.

SOSL Return Type

Each SOSL query returns a list of lists of sObjects. A variable of type List<List<SObject>>can be used to store the results of a SOSL query in Apex. Example: FIND {test} RETURNING Account (Id), Contact, Opportunity LIMIT 60

What is the purpose of SeeAllData=true annotation?

Enables test classes to access actual records that exist in the org.

Which communication model is used by the Lightning Component framework?

Event-driven model

Flow Limits - Elements

Executed elements at runtime per flow: 2,000. For each flow interview, you can only have a maximum of 2,000 elements being executed. Note that if you have a loop, the elements within the loop (including the loop element) will be multiplied by the number of iterations. For example, if you have 100 records that enter a loop with two elements, the total elements will be 200

Apex Scenario A developer is building a custom Lightning component that should allow searching for a keyword entered by a user in all the leads and contacts. The search should return the Id and Name of each lead and contact

FIND {key} IN ALL FIELDS RETURNING Lead(Id, Name), Contact(Id, Name)

Apex Design Patterns - Factory Pattern

Factory pattern is one of the most used design patterns in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object.

Where can you view Failed Flows?

Failed interviews of Screen, Record-triggered, Schedule-triggered, and Autolaunched flow type can be viewed in the Failed Flow Interviews list view in Setup.

You can import and export scheme definitions with Schema Builder?

False

Enforcing Object and Field Permissions - 2

Field-level security

Which automation tool can be used to create process that allows users to insert an image from a screen?

Flow Builder

Flow Builder - 1

Flow Builder can be used for more complex requirements and capable of providing more advanced functionality.

Which formula functions are supported by Flow Builder in record-triggered flows?

Flow Builder supports the use of the ISCHANGED, ISNEW, and PRIORVALUE formula functions in record-triggered flows

Process Automation Tools

Flow Builder, Process Builder, Workflow, and Approvals are declarative tools that can be used to automate repetitive business processes.

What class do you use to invoke flow from Apex?

Flow.Interview system class Study slide

Screen Flows - Addl Info

Footer buttons: The footer of a screen flow comes with the standard buttons: Next or Finish, Previous, and Pause. These buttons support custom labels and translations using Translation Workbench.

Which method can use a SOQL query to retrieve data to for display on a VF page?

Getter method

Getter methods

Getter methods are used to return values from the controller. 1. Display values: Every value that is calculated by a controller and displayed in a page must have a corresponding getter method. 2. Expression syntax: Expressions in VF page markup using the general pattern {! expression_name } automatically connect to the getter method to get access to the data 3. Run Queries: It is possible for a getter method to contain a SOQL query that retrieves data to display on the VF page. For example, it can execute a SOQL query to get a list of account records, and then return the list to the VF page that calls the method

Which governor limit can be exceeded when a trigger is not designed to handle several thousand records?

Governor limit for DML statements per transaction

Types of Flow - Screen Flow

Guides users through a business process that's launched from Lightning pages, Experience Cloud sites, quick actions, and more.

Which clause can be used to filter the results returned by an aggregate function in a SOQL query?

Having

What can you access under the Checkpoint Inspector?

Heap: TIS (Types, Instances, State)

Database Class Methods

Here are other database operations that can be performed using Database Class methods:

Record or Object Awareness - Lightning Web Component

If a Lightning web component needs to retrieve the Id or object API name of the record where it is used, the public properties recordId or objectApiName respectively need to be added in the component

Can relationships be changed?

If a master-detail relationship is not used in a roll-up summary field, it can be converted to a lookup relationship, and also vice versa as long as the lookup relationship field contains values in all of its records.

Void keyword

If a method does not return a value, the void keyword should be used instead of a return type

Which key word is used by a class to use an interface?

Implements

What does it mean to overload an Apex constructor?

In Apex, a constructor can be overloaded, that is, there can be more than one constructor for a class, each having different parameters.

MVC Architecture

In application development, the MVC is an architectural pattern that separates the data layer from the business logic and how the data is presented in the user interface

Which code can be defined for HTML tags like in a regular HTML page?

Inline CCS code

Best Practices for Apex Classes & Triggers - USE DML STATEMENT OUTSIDE THE FOR LOOP

Instead of placing a DML statement inside a for loop to perform operations such as insert, update, delete, and undelete, the records that need to be inserted or modified should be added to a list and a single DML statement should be invoked on that list after the execution of the for loop

Best Practices for Apex Classes & Triggers - USE SOQL QUERY OUTSIDE THE FOR LOOP

Instead of placing a SOQL query inside a for loop to retrieve the data, a single query should be used outside the for loop to retrieve all the necessary data, and then the for loop logic should iterate over the results. This is to ensure that the Apex code does not reach the governor limit for the maximum number of SOQL queries that can be executed in an Apex transaction

Best Practices for Apex Classes & Triggers - USE MAPS FOR SOQL QUERIES

Instead of using a for loop, a map can be used to obtain records from a SOQL query, which is a more efficient approach. The following technique can be used: Map<Id, sObject> m = new Map<Id,sObject>(SOQL Query);

Visualforce Controllers Overview - Standard List Controllers

Invoked using standardController and recordSetVar attributes of <apex:page> componen

Visualforce Controllers Overview - Customer Controllers

Invoked using the controller attribute of the <apex:page> component

What is an sObject?

It's a virtual superclass that can be used to refer to any object that can be stored in the Lightning Platform database.

For member methods, you need a new instance of a class; for a static method, you use dot (.) notation

Key point

Lightning Web Security (LWS)

LWS, which is a client-side security architecture designed for Lightning web components, prevents the components from accessing data or interfering with components from other namespaces.

Which property of an object or field can be changed when it is referenced in Apex code?

Label Name

Types of Flow - Schedule Triggered Flow

Launches at a specified time and frequency for each record in a batch. This Autolaunched flow runs in the background.

Types of Flow - Platform Event Triggered

Launches when a platform event message is received. This Autolaunched flow runs in the background.

What time of exception is thrown when a transaction hits a governor limit?

Limit Exception

Trigger.newMap

Map of all records in the trigger. The key used in the map is the record ID, and the value is the record itself.

Debug Log Levels

NONE ERROR WARN INFO DEBUG FINE FINER FINEST

Lightning web components do not use 'bubbles: false and composed: true'.

Not supported

Enforcing Object and Field Permissions - 1

Object-level and field-level permissions can be enforced through code by explicitly using sObject and field describe result methods. The following describes some of these methods.

NullPointer Exception

Occurs when there is a problem dereferencing a null variable

Record-Trigger Flow Triggers - A a record is deleted

Optimize flow for: 1. Before the record is deleted: the flow can access any record and perform actions before the triggering record is deleted from the database. To create, update, or delete other records, add Create Records, Update Records, and Delete Records elements to your flow. The $Record global variable contains the Salesforce record that launches the flow.

When you debug record-triggered flows, you need to explicitly enable rollback mode?

Option is disabled as debugging will always run record-triggered flows in rollback mode.

Where should database operations occur in a trigger?

Outside for loops

What is necessary so that you can override a tab with a VF page?

Overriding tabs only works when the VF page uses 1. The standard list controller for that tab 2. A custom controller 3. No controller

Within flow, what do the PRIORVALUE and ISCHANGED use?

PRIORVALUE and ISCHANGED functions use the $Record global variable to reference fields in the current record

Platform Event vs Custom Object

Platform events are similar to custom objects and are defined in the same way as a custom object. Aside from their use case, the following lists some of their main differences.

Using platform events - 1

Platform events are used to deliver near real-time notifications in the Salesforce platform or in an external application.

Accessing Private or Protected Members Outside a Test Class

Private or protected members can be exposed to test classes by using an annotation

NullPointerException

Problem with dereferencing a null variable

Which automation tools can be used to create records?

Process Builder and Flow

Process Builder

Process Builder can be used to perform actions as the result of multiple if/then statements

Publishing Platform Events with Process Builder

Process Builder can be used to publish platform events. Creating a platform event record publishes a platform event message.

Process Builder - Record Changes

Process builder can be used to update parent or child records, or create new records.

Which class can contain reusable code for test data creation?

Public test utility class, also known as Test Data Factory

Universal Containers (UC) decided it will not to send emails to support personnel directly from Salesforce in the event that an unhandled exception occurs. Instead, UC wants an external system be notified of the error.What is the appropriate publish/subscribe logic to meet these requirements?

Publish the error event using the Eventbus.publish() method and have the external system subscribe to the event using CometD.

What is QueryException?

QueryException will be raised for any Apex problems with SOQL queries (no records returned or more than one record assigned to an sObject variable)

REST vs SOAP APIs

REST APIREST API: provides a way to programmatically access or process Salesforce data from an external application via REST-based web services. Use this API when developing web or mobile applications that need to integrate with Salesforce. SOAP API: Similarly, SOAP API lets developers access, search, and perform DML operations on records from an external application via the SOAP messaging protocol. Use SOAP API in any languages that can work with web services such as Java or C++.

SOQL Relationship Queries

Relationship queries, based on lookup and master-detail relationships enable retrieving of data from related records. 1. Traverse Relationships: SOQL relationship queries traverse parent-to-child and child-to-parent relationships between objects to filter and return results 2. Return Related Objects: Objects of one type can be returned based on criteria that applies to objects of another type. 3. Child-to-Parent Query: Child-to-parent relationships can be specified directly in the SELECT, FROM, or WHERE clauses using the dot (.) operator.

Which types of declarative changes are impacted by the use of Apex?

Renaming a field, deleting a field, or changing the type of a field

Which design supported by the Lightning Component Framework ensure compatibility with different devices?

Responsive design

Database Class Methods - ROLLBACK

Restores the database to the state specified by a save point variable

getSelected() in the StandardSetController.

Returns the list of sObjects that have been selected.

SOQL Wildcard - LIKE

SELECT Id, LastName FROM Contact WHERELastName LIKE 'Ab%'

SOQL Injection

SOQL injection is a technique that is used to inject values to manipulate the construction and outcome of a dynamic SOQL query.

What can be used as a basis for a custom list controller?

SOQL query - confirm

SOQL Joins

SOQL supports join patterns that utilize relationship traversal in path expressions. 1. Outer Joins: Outer joins can be used to return all data from the first object and the matching data from the second object. 2. Inner Joins: Inner joins can be used to return data from the first object that has related data in the second object 3. Anti-Joins: Anti joins can be used to return data from the first object that does not have related data in the second object.

SOSL - Additional Information

SOSL can be used when the object or field where the searched data resides in is not known

Where can a Lightning Component be made available?

Salesforce Mobile App, Lightning Experience, and Communities

SOQL

Salesforce Object Query Language: Allows SQL like commands to search for specific fields within salesforce objects. Can query one standard or custom object at a time.

Test Data Sources Overview

Salesforce allows several options for providing test data to test classes

Metadata-Driven Kernel

Salesforce uses a runtime engine that materializes all application data from metadata, which is data about the data itself

How can you include JavaScript in VF pages?

Save it as a static resource and reference it via <apex:includeScript> <apex:includeScript value="{!$Resource.MyJavascriptFile}"/>

Setter Methods

Setter methods can be used to submit values from the Visualforce page back to the controller

Setter Methods

Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods. Apex Controller <-- Setter <--- VF Page

Configuration File

Similar to an Aura component's design resource file, a Lightning web component uses a configuration file for the following

Apex Design Patterns - Facade Pattern

Simplifying the execution of classes with complex interfaces (e.g. web service callouts) Factory

Empty Subquery Results

Since a subquery also returns results in a list format, the isEmpty() method can be used to determine if a subquery returned any results.

What can VF Apex extensions be used with?

Standard controller or custom controller

Static methods, variables, and initialization code

Static methods, variables, and initialization code have these characteristics: - They're associated with a class - They're allowed only in outer classes - They're initialized only when a class is loaded - They aren't transmitted as part of the view state for a Visualforce page

What should be used instead of dynamic SOQL to prevent SOQL injection?

Static query with a bind variable

Sync vs. async limits

Sync - transaction happens immediately Async - logic happens later in time (5 to 15 minutes later); good for heavy, complex, calculations, a lot of data, or the Salesforce platform is busy.

Which method can be used to verify whether a test achieves expected results?

System.assert()

What syntax do you use to get the total number of queries allowed?

System.debug('Before SOQL - Total Number of SOQL Queries Allowed' + Limits.getLimitQueries());

Component Tests

Test files for a Lightning web component are contained in a subfolder inside the component's folder

What can be used to populate test data without using code to create test records?

Test.loadData method with a static resource for the csv file containing test records

Start and Stop Test

Test.startTest() and Test.stopTest() methods, which can only be called once in each test method, can be used in conjunction with Limits methods to test governor limits by determining the proximity of Apex code to reaching the governor limit. The startTest and stopTest methods mark the point where the testing of code actually begins and ends. Code before actual test begins should be used to set up the scenario such as initializing variables and creating test data.

SOQL Wildcard - %

The % wildcard matches zero or more characters

When using VF, what does <apex:detail/> show?

The <apex:detail/> component displays the standard view page for a record. It shows related lists as well.

How do you embed JavaScript in a VF page?

The <apex:includeScript> tag and $Resource global variable are used to reference JavaScript files in static resources

DescribeSObjectResult Class Methods - 1

The DescribeSObjectResult class has instance methods for describing sObjects

DescribeTabResult Class Methods

The DescribeTabResult class has instance methods for obtaining metadata information for a tab in a standard or custom app in Salesforce.

DescribeTabSetResult Class Methods - 1

The DescribeTabSetResult class has instance methods for obtaining metadata information about a standard or custom app in Salesforce.

What is DOM?

The Document Object Model (DOM) is the language-independent model for representing and interacting with objects in HTML and XML documents.

SOQL HAVING

The HAVING clause can be used to filter the results returned by an aggregate function in a SOQL query. Example: SELECT Name, Count(Id) FROM Account GROUPBY Name HAVING Count(Id) > 1

Component HTML File

The HTML file serves as the presentation layer of the Lightning web component. Unlike service components, UI components require this file.

Lightning Component Framework

The Lightning Component Framework is a UI framework that allows building single-page web apps with dynamic and responsive user interfaces in Salesforce. It uses JavaScript on the client side and Apex on the server side. Some of its main features are as follows

MVC Architecture & Lightning Components

The Lightning Component Framework is not strictly based on the MVC architecture. Aura and Lightning web components follow the MVCC (Model-View-Controller-Controller) pattern.

RecordTypeInfo Class Methods

The RecordTypeInfo class has instance methods for accessing record type information for an sObject with associated record types.

SOQL select statement

The SELECT command is used to select fields that need to be returned. Only fields included in the query are returned. However, note that executing a SOQL query in Apex always returns the ID field.

SObjectField Class Methods

The SObjectField class has instance methods to return the describe field result for a field

Apex Design Patterns - Singleton Design pattern in Apex

The Singleton pattern is a creational pattern - it helps you to instantiate objects in a particular way. It allows for the existence of only one instance of an object, but everyone has global access to that object. Singletons can help improve performance and reduce memory footprint.

Apex constructor method

The access modifier is followed by the name of the method, with same name as class; it does not return anything

addError()

The addError()method can be called on a record or field to prevent DML operations from committing.

Difference between an abstract and virtual class

The basic difference between a virtual and abstract class is that methods in virtual class CAN be overridden in derived classes, while abstract class methods MUST be overridden.

Escape Single Quotes Example

The below illustrates how the escapeSingleQuotes method adds escape slashes to a string value

Break Statement

The break statement can be used conditionally within a procedural loop statement to exit the entire loop. When encountered, any remaining loop iteration will not be executed

Apex Design Patterns - Builder Pattern

The builder pattern is a creational pattern - it helps you to instantiate objects in a particular way. This pattern allows you to construct complicated objects step by step. Builders help to populate immutable private variables at construction without a multiple position-based constructor arguments.

Invoking Apex from Flow using Process.Plugin - 1

The built-in Process.Plugin interface allows one to process data and pass it to a flow: 1. Input & output: the interface exposes the Apex class as a service that accepts input values and returns output back to the flow 2. Unsupported data types: Blob, Collection, sObject, and Time data types are not supported by Process.Plugin. 3. Interface implementation: An Apex class that implements the interface needs to be created to make it available in the palette of Flow Builder.

@isTest

The class is defined with the @isTest annotation. This annotation is used to mark the class as a test class to contain test methods that Apex can execute.

Best Practices for Apex Classes & Triggers - BULKIFY TRIGGER CODE

The code defined in an Apex trigger should be able to process a batch of records instead of one record at a time. For example, if a trigger is invoked by a SOAP API call that inserts a batch of 200 records, all those records should be processed as a bulk in the trigger to ensure scalability and avoid hitting governor limits

DML - Delete

The delete DML statement is used for deleting records.

Which method can be used to retrieve metadata information for individual objects?

The describeSObjects() method

What happens if you delete a detailed record and then a master and then you restore the master?

The detailed is not automatically restored - it can only be restored if it's still in the recycling bin.

Do-While Loop

The do-while loop can be used when the loop needs to be executed at least once.

When to Use Orchestrator

The following are some applications where the Orchestrator can be utilized: - Advanced approval processes - Shipment processing systems - HR Onboarding processes that includes multi-steps and multi-user tasks - Group task list

Using SOQL Query in Apex

The following code snippet shows how a SOQL statement is used in Apex code.

VF - iFrame Component

The iframe component can be used to display an external website in Salesforce.

DML - Insert

The insert DML statement is used for inserting new records.

DML - Merge

The merge DML statement is used for merging records into a single record: 1. Merge Limit: The merge statement can be used to merge up to three records of the same sObject type. 2. Merge Keyword: The merge keyword followed by the master record and any otherrecords can be used to perform the merge DML operation.

Accessing the Data Model Programmatically - 1

The metadata of an sObject, which is a representation of any Salesforce record, can be accessed using 1. tokens 2. describeSObjects Schema method

SOSL LIMIT

The optional LIMIT clause can be added to a query to specify the maximum number of rows that are returned in a search result.

SOSL Ordered By

The order of the results that are returned from a query can be specified.

Check user permissions

The permission assignment of the current user can be used to customize the behavior a component. To check permissions, the @salesforce/userPermission and @salesforce/custom Permission scoped modules are used

PubSub Module

The pubsub module can be used in containers that do not supportLightning Message Service. It utilizes the publish-subscribe pattern: one component publishes an event, while other components subscribe to receive and handle the event.

What does this SOQL query return? SELECT Id, Name, Mother__r.Name, Father__r.Name FROM Child__cWHERE Father__r.Name LIKE 'Bill%'

The query returns the name (Name), mother's(Mother__c) name, and father's (Father__c) name of child (Child__c) records that match a criteria This is a child to parent query Note: Subqueries can use the WHERE clause, which applies to the object in the FROM clause of the subquery.

recordSetVar

The recordSetVar attribute not only indicates that the page uses a list controller, it can indicate the variable name of the record collection. This variable can be used to access data in the record collection.

SOSL Query Example

The results from a specific object can be retrieved by specifying its index value in the list of objects using array notation. For example, the results of the first object can be retrieved using [0]. Need to understand

Execution Result Example

The sample code that uses the Flow.Interview.flowName syntax prints the following in the debug log when executed. The getVariableValue() method retrieves the flow variable.

Uses of Visualforce Controllers - 1

The standard controller and standard list controller can be used to implement standard functionality.

What's true about overriding standard buttons with a VF page?

The standard controller for the object in which the button appears must be used.

Standard Set Controller

The standard set controller allows a developer to build functionality that is not available in the standard list controller.

In the Account.Name example, what do you call Name?

The static member variable name of an sObject static type, such as Account.Name, can be used to access the field token.

How can you retrieve the token for an sObject or field?

The token for an sObject or field can be retrieved by accessing the static member variable name, or by using a method.

DML - Update

The update statement is used to updating existing records.

DML - Upsert

The upsert statement is used to either insert a new record, or update an existing record, in one call 1. Identifying existing record: To determine whether a record already exists, the upsert statement or Database method uses the ID of the record as the key to match records, a custom external ID field, or a standard field with the idLookup attribute set to true. 2. Insert or update record: If the key is not matched, a new object record is created. If the key is matched once, the existing object record is updated. 3. Error on multiple matches: If the key is matched multiple times, then an error is generated and the object record is neither inserted or updated.

What happens when process builder invokes an Apex class?

The user whose action triggers the process also executes the Apex class. Note: does the class run in system mode?

Including a Lightning Component in VF page

There are three steps to add Aura components to a Visualforce page. 1. Add the Lightning Components for Visualforce JavaScript library to your Visualforce page using the <apex:includeLightning/> component. 2. Create and reference a Lightning app that declares your component dependencies. 3. Write a JavaScript function that creates the component on the page using $Lightning.createComponent(). 4. Need $Lightning.use

@testVisible

This annotation can be used in the definition of any private or protected variable, method, or inner class to make it visible to a unit test class; with this annotation it's possible to access methods and member variables without changing their access modifiers.

apex:pageMessage

This component should be used for presenting custom messages in the page using the Salesforce pattern for errors, warnings and other types of messages for a given severity. See also the pageMessages component.

Getting sObject Metadata Programmatically

This example shows how to retrieve sObject metadata programmatically

Invocable Method Configuration in Flow Builder

This example shows the options available for configuring an invocable Apex method

What are the frequencies for scheduled flows?

This flow can be scheduled to run once, daily, or weekly

Bath Apex - Execute method

This method takes the following: 1. A reference to the Database.BatchableContext object. 2. A list of sObjects, such as List<sObject>, or a list of parameterized types. If you are using a Database.QueryLocator, use the returned list.

Loading Static Resources in LWC

To access static resources in a Lightning web component, the @salesforce/resourceUrl scoped module is imported.

Two Apex interfaces, namely MyInterfaceA and MyInterfaceB, exist in an org. A developer is required to create an Apex class that implements these two interfaces for a new functionality required in the org. The name of the Apex class to create is called MyClass and should be accessible globally. How should the Apex class be declare

To allow an Apex class to be used globally, or by any Apex code in the org, the global keyword is used in the class definition. An Apex class can implement multiple interfaces by separating the names of the interfaces with a comma.

Test Class for Future Methods

To test methods defined with the future annotation, call the class containing the method in a startTest(), stopTest() code block. All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously.

When using SalesforceDX, what does a developer need to enable to create and manage scratch orgs?

To work with scratch orgs, first enable the Developer Hub (Dev Hub) in your production or business org. You can then use Salesforce Extensions for VS Code or Salesforce CLI to create scratch orgs. You have two ways of managing your scratch orgs: using CLI commands or the Salesforce graphical interface.

Transaction Finalizer - 1

Transaction Finalizers implement an interface which enable them to attach actions to a queueable Apex job.

Trigger Timing

Trigger.isBefore Trigger.isAfter Can be used to determine if the trigger was fired before any records were saved or after all records were saved.

TRIGGER.ISEXECUTING

Trigger.isExecuting can be used to determine if the current context of an Apex code that is being executed is a trigger.

Formatted joined reports can be exported, preserving their layout. They are always in XLSX format.

True

The $Record global variable contains the current field values and the $Record__Prior global variable contains the prior field values

True

There is no Array data type in Apex.

True

Which three values can be assigned to a Boolean?

True, false, null

Types of Lightning Web Components

UI vs server

UI Test Automation Model (UTAM)

UTAM is an open-source tool built by Salesforce which can be used to test any web page and is ideally suited for writing JavaScript or Java UI tests for Lightning web components

Best Practices for Apex Classes & Triggers - DESIGN TESTS TO VERIFY BULK OPERATIONS

Unit tests should be designed to verify that Apex triggers can handle large datasets and not just single records. Test.startTest and Test.stopTest should be used to utilize a fresh set of governor limits.

How can you embed a flow into an Aura Component?

Use the following tab: Lightning:flow

When is the standard list controller used?

Used for displaying or working on a set of records and comes with built-in pagination features such as next and previous actions for browsing record lists.

When creating trace flags, what are the options (traced entity type)?

User Automated Process Platform integration Apex class Trigger

Data Access Control - Explicit Declaration

Using an explicit 'inherited sharing' declaration makes the intent clear, avoiding ambiguity arising from an omitted declaration or false positives from security analysis tooling.

How can you expose Salesforce Apex classes to to external applications?

Using the Apex REST API (use REST principles)

Count() Function

Using the Count() function in a SOQL query counts as one query row toward the limit.

How can values in a record about to be saved be accessed and modified

Using the Trigger.new trigger context variable

Menu Items in the Salesforce Mobile App - VF

Visualforce can be used to extend the Salesforce mobile app

A report with a custom format used by the business needs to be generated and rendered as a PDF file on a page.

Visualforce code can be used to generate a report that uses a custom format. It can be rendered as a PDF file as well. <apex:page renderAs="pdf">

Which VF overrides are available for Lightning Console Apps?

Visualforce overrides are supported for new, edit, view, tab, list, and clone in Lightning console apps.

Additional use cases for blob

Web service argument, body of a document, or attachment

Apex Constructor

When a constructor is not explicitly defined, a default, no-argument, public constructor is used.

Parent and Grandparent Records

When a parent/grandparent is updated due to its roll-up summary fields or cross-object field updates, an entire order of execution will be performed for each record, but excluding the database commit

Invocable variables

When an Apex class is used as an input or output parameter for an invocable method, the class member variables that need to be available to the method should be annotated with @invocableVariable Note: The required attribute is used to specify the variable as required when the class is passed as an input parameter. When used as an output, this attribute is ignored.

Generate more flow interviews

When handling a larger amount of data, people usually hit the element limit first before the number of records limit. To prevent this, utilize the bulkification feature of Record-Triggered (RT) and Schedule-Triggered (ST) Flow. Bulkification is a complex topic, but try to remember this advice: Build your RT/ST flow as if it is for one record for the triggering object. Salesforce will then batch the records whenever it can. This can help you effectively avoid the element constraint - you can take a look at my experiment if you want to dig a little deeper.

What happens when a generic exception is used?

When the generic Exception is used, it must be implemented as the last catch block.

Aura Component Bundle

When using the Aura Component programming model to build an application, an Aura Component bundle is created.

Defining Event Propagation Behavior

While creating a custom event, a configuration can be passed to indicate whether the event should bubble up through the DOM and/or cross the shadow boundary.

Can you test code as different user?

Yes - Salesforce allows executing code in the context of a specified user for testing by using the System.runAs method.

Delete DML

You can delete persisted records using the delete statement. Deleted records aren't deleted permanently from Lightning Platform, but they're placed in the Recycle Bin for 15 days from where they can be restored.

How can you create scratch orgs?

You have the option to use Salesforce Extensions for VS Code or Salesforce CLI to create scratch orgs

Method syntax

[public | private | protected | global] [override] [static] data_typemethod_name (input parameters) { // body of the method}

Which three options allow a developer to use custom styling in a Visualforce page?

apex:stylesheet> tag Inline CSS Static resource

Batchable Apex - Finish Method

global void finish(Database.BatchableContext BC){} The finish method is called after all batches are processed. Use this method to send confirmation emails or execute post-processing operations.

Additional Ways to avoid heap size

https://bit.ly/3rlHaq2 1. Use efficient algorithms 2. Leverage built-in Apex libraries 3. Avoid using temporary variables 4. Shorten variable names & declarations 5. Shorten field API name 6. Remove unnecessary debug statements

What actions are available with Data Import Wizard?

insert, update and upsert

What part of the MVC do Salesforce Objects map to?

model

Here are some ways you can create your exceptions objects, which you can then throw - With a single String argument that specifies the error message

new MyException('This is bad');

Here are some ways you can create your exceptions objects, which you can then throw - With no arguments

new MyException();

Security Scenario A VF page that uses a custom controller allows a user to enter the name of an account and perform a search. The custom controller contains the following method that uses dynamic SOQL to find the account record, where name is the value of the account name provided by the user and queryResult contains the record returned by the query: publicPageReferencesearch() { Stringquery = 'SELECT Id FROM Account WHERE Name LIKE \'%' + name + '%\''; queryResult = Database.query(query); return null; } However, if a user enters a value such as null%' OR Name LIKE ', the query returns all the account records. An appropriate measure is required to prevent this SOQL injection.

o prevent SOQL injection in this scenario, instead of using dynamic SOQL, the search() method should use a static SOQL query with a bind variable to retrieve the account record: publicPageReferencesearch() { String queryName = '%' + name + '%'; queryResult = [SELECT Id FROM Account WHERE Name LIKE :queryName]; } If a user provides the value of null%' OR Name LIKE ', then the SOQL query tries to find account records using the comparisonName LIKE '%null%' OR Name LIKE %'', which should ideally not match any records.

To create your custom exception class, extend the built-in Exception class and make sure your class name ends with the word Exception. Append extends Exception after your class declaration as follows.

public class MyException extends Exception {}

Casting an sObject

sObject s = new Invoice_Statement__c(); Invoice_Statement__c inv = new Invoice_Statement__c(Description__c='Test Invoice', Status__c='Pending'); Invoice_Statement__c inv = (Invoice_Statement__c)mySObjectVar;

If two sObjects are related to each other via a relationship, you can get a parent sObject of an sObject using the dot notation syntax

sObjectTypeName parentObject = objectA.RelationshipName;

Orchestration Types

the orchestration type determines how an orchestration is launched or distributed: 1. An auto-launched orchestration type does not require record triggers. It can be launched through apex classes, custom buttons, or custom links. 2. A record-triggered orchestration only runs when a record is changed or created.

Upsert syntax

upsert sObjectList Account.Fields.MyExternalId; If the key is not matched, a new object record is created. If the key is matched once, the existing object record is updated. If the key is matched multiple times, an error is generated and the object record is neither inserted or updated.

Scheduled Path Example - The source of the scheduled time and offset can be specified when configuring a scheduled path

x... 1. Days after 2. Days before 3. Hours after 4. Hours before 5. Minutes after 6. Minutes before Note: The batch size or the number of records to be processed at a time can also be specified.

Future method callouts using @future(callout=true)

To allow callout from the future method annotation needs an extra parameter (callout=true) to indicate that callouts are allowed. Example attached.

ApexPages.StandardController controller

To also work with a Standard Controller, overload the constructor to take a different parameter type. That is, add a second constructor method that takes an ApexPages.StandardController parameter.

Failed Flow Interviews

Clicking on the failed flow link in the email opens up the saved flow interview in Flow Builder such as the below example. This allows more efficient troubleshooting and debugging

Inner classes require access modifiers

False.

You can delete objects with changes.

False.

You can do relationship searches with SOSL.

False.

Flow - publishing platform events:

Flow Buildercan be used to publish platform events. Creating a platform event record publishes a platform event message.

Flow Trigger Explorer

Flow Trigger Explorer is a tool for viewing record-triggered flows that are associated with a specified object and identifying how or when they are triggered based on a record change.

Invoking a Flow Dynamically

Flows can be called from an Apex method dynamically by using the createInterview method

What does Einstein Next Best Action rely on?

Flows, recommendations, strategies, and components

Types of Displayed Data in Visualforce

Merge field syntax is used to display related object records that are up to five levels of child-parent and 1 level of parent-child relationships away

What is the value of the Trigger.old context variable in a Before Insert trigger?

Null (not undefined)

Trigger Context Variable: size

Number of records the trigger is working with

View Orchestration Work Items

Orchestration items are listed on the Orchestrator Work Guide component and Orchestration Work Items list view. Work items can be reassigned from one user to a different user, group, or queue

DescribeSObjectResult Class Methods - 2

The DescribeSObjectResult class also has instance methods for checking the current user's object permissions. Reviewed during Sharing & Visibility; object-level permission for current user.

SOQL FIELDS() Function

The FIELDS() function can be used in a SOQL statement to query records without specifying the field names of the object. The function accepts three types of values.

SOQL GROUP BY

The GROUP BY clause can be used to specify a group of records to avoid iterating through individual query results. Example: SELECT LeadSource, COUNT(Name) FROM Lead GROUP BY LeadSource

SOQL IN

The IN or NOT IN operator can be used in a WHERE clause to filter on a set of values. Example: SELECT Id FROM Account WHERE AccountNumber IN : integerList

SOQL INCLUDES and EXCLUDES Operators

The INCLUDES and EXCLUDES operators use semicolon and comma characters to build specific AND/OR logic respectively for matching values in a multi-select picklist field.

Using the Is Changed Operator

The Is Changed operator can be used to execute flow actions or determine a decision outcome depending on whether a field value changed in the current transaction.

Within flow, where is the IsChanged operator available?

The IsChanged operator is available in the Decision Element as well as the Start Element for flows that are triggered when a record is updated.

What JSENCODE function will do?

The JSENCODE function encodes text strings and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').

Component JavaScript File

The JavaScript file is required in any type of Lightning web component. It contains the client controller that includes the properties and functions of the component.

ApexPages.StandardSetController

The constructor method takes an object as its only parameter. This allows the class to be used as a Visualforce controller extension with a Standard List Controller. Example: public WarehouseUtils(ApexPages.StandardSetController controller) { }

Continue statement

The continue statement can be used conditionally within a procedural loop statement to skip the current iteration and jump to the next iteration. When encountered in a loop, the current iteration is instantly terminated and the next iteration in the loop will be started.

BUBBLES:FALSE, COMPOSED:FALSE

The default configuration is 'bubbles: false and composed: false'. It means that the event does not bubble up through the DOM and does notcross the shadow boundary.

What are some limits of Schedule-Triggered Flows?

This flow type can onlyrun at the time and frequency that it's scheduled and does not support user interaction, screens, local actions, choices, or choice sets

Relationship Queries - TYPEOF clause

This option uses the TYPEOF clause where specific fields can be returned based on the object type: List<Event> events = [SELECT TYPEOF What WHEN Account THEN Website, NumberOfEmployees WHEN Opportunity THEN StageName, Amount END FROM Event]; Study

What are the requirements so that a VF page can be used on a dashboard?

To be included in a dashboard, a Visualforce page must: 1. Have either no controller 2. Use a custom controller 3. Reference a page bound to the StandardSetController Class.

Debugging Flows After Pause Elements

To continue debugging after the Pause element, the Continue the Debug Run button is clicked after the Pause Path is selected. Note that when the Resume Event settings of a Pause element is time-based, the flow interview resumes in system context without sharing by default. To resume in the same user context or user access settings that was used to pause the flow, the Make Paused Flow Interviews Resume in the Same Context with the Same User Access settings in Setup can be activated.

Any statements in the try block occurring after the exception are skipped and aren't executed. For example, if you add a statement after insert m;, this statement won't be executed.

To continue the execution of code statements after an exception happens, place the statement after the try-catch block. try { Merchandise__c m = new Merchandise__c(); insert m; } catch(DmlException e) { System.debug('The following exception has occurred: ' + e.getMessage()); } // This will get executed System.debug('Statement after insert.');

Deleting Components from an Organization

To delete components, use the same procedure as with deploying components, but also include a delete manifest file that's named destructiveChanges.xml and list the components to delete in this manifest. The format of this manifest is the same as package.xml except that wildcards aren't supported.

How can you ensure a triggers is called only once? Really important point

To ensure a trigger is called only once, before the trigger code is executed, a class with a static method / variable can be called to check and set if the code has already been run as part of the transaction.

Importing Articles - 2

To import, a .zip file containing the following needs to be uploaded

Asynchronous Path Configuration

To include an asynchronous path in a record-triggered flow, the option can be enabled when selecting the Actions and Related Records in the Start configuration window.

Invoking a Batch Class

To invoke a batch class, instantiate it first and then call Database.executeBatch with the instance of your batch class: BatchClass myBatchObject = new BatchClass(); Database.executeBatch(myBatchObject);

Invoking a Batch Class

To invoke a batch class, simply instantiate it and then call Database.executeBatch with the instance: MyBatchClass myBatchObject = new MyBatchClass(); Id batchId = Database.executeBatch(myBatchObject);

What are the requirements for invoking Apex via a Lightning Component?

To invoke an Apex method, it must be annotated with @AuraEnabled and be static and either global or public. Note that overloading is not allowed for @AuraEnabled methods.

What are two ways to reference images in VF pages?

To load images on a page, the <apex:image> tag can be used Images can be referenced from: 1. a static resource 2. Tt can be referenced from an external URL.

Accessing a private variable or method from outside the class will throw an error.

True

All after triggers are executed BEFORE after-save record-triggered flows are executed.

True

All standard Visualforce components, which start with <apex>, have anti-XSS filters in place to screen out harmful characters.

True

All variables have the value of null if they are not assigned a value during initialization.

True

An Apex class can only extend one other class, but it can implement more than one interface.

True

An Aura component may contain a Lightning web component, but the inverse is not allowed.

True

Apex extensions can be re-used on multiple VF pages

True

Before-save record-triggered flows are executed BEFORE all before triggers are executed

True

Bounded queries, such as FIELDS(STANDARD), return a predetermined set of fields. Fields of unbounded queries, such as FIELDS(ALL) and FIELDS(CUSTOM), are not predetermined.

True

Code coverage is only generated when executing Apex test classes or unit tests

True

Constructors used by VF custom controllers cannot include parameters.

True

Debug logs don't contain information about time-based workflows

True

Declaratively, only flow can be used to delete records.

True

Dynamic sorting is not available through standard list controllers. A custom controller is required for this feature.

True

Fields on related records can't be updated with the same call to the DML operation and require a separate DML call

True

For before triggers, a DML statement on the object that invoked the trigger will throw an sObjectException

True

Formula fields can be used in SOQL quries

True

If a Apex qproperty has only a get accessor, it is considered read only. If a property has only a set accessor, it is considered write only. A property with both accessors is considered read-write.

True

If any class implements an interface, you can be guaranteed that the methods in the interface will appear in the class. Many different classes can implement the same interface.

True

In Apex, string is any characters within single quotes; using double quotes causes an error in Apex.

True

Parent and child Lightning web components can communicate through events using the bubbling phase only.

True

Platform events only support after insert events.

True

Platform events only support after insert triggers.

True

Recycling Bin manipulation counts as a DML transaction

True

Salesforce CLI and SOAP/REST API can perform unbounded queries only if the results rows are limited (such as using LIMIT)

True

Static variables are only static within the scope of the request. They are not static across the server, or across the entire organization.

True

Test code cannot actually send callouts to external systems, so you'll have to 'mock' the callout for test coverage.

True

The Database.emptyRecycleBin() method, regardless of how many records are processed in a single call, increments the DML counter by 1 only regarding the number of DML statements issued.

True

Trigger.new records can only be edited in Before Triggers

True

Unlike static queries, any syntax errors in a string query will only be detected during run time.

True

Using definition modifiers such as virtual and abstract are not required in a class definition.

True

Visualforce pages that use the Standard Controller can't be used in dashboards.

True

You can't call a future method from a future method. Nor can you invoke a trigger that calls a future method while running a future method.

True

You're limited to 50 future calls per Apex invocation, and there's an additional limit on the number of calls in a 24-hour period

True

Aggregate functions such as COUNT() and SUM() can be included in the HAVING clause but not the WHERE clause.

True.

Commit and post-commit only happen once at the end of the transaction

True.

Directly assigning an Integer to a Decimal is allowed, but the doing the opposite will throw an error.

True.

Multiple classes can implement the same interface

True. Interfaces are used mainly for providing the abstraction layer for your code. They separate the implementation from declaration of the method.

Standard report types are created for each lookup relationship

True. It's chosen to true by default when creating lookup.

When using SOQL with Apex, there are no DML transactions.

True. Only used to retrieve data and bound by governor limits.

Describe Result

Two Apex classes called DescribeSObjectResult and DescribeFieldResult are available to describe sObjects and fields.

Accessing the Data Model Programmatically - 2

Two data structures and a Schema method are used for accessing sObject and field describe information in Apex.

Key Point About Debugging Flows

Two options are available for the debug run behavior of a record-triggered flow. It can be run as if the record is created or updated

Positive and Negative Cases in Test Classes

Units tests should include both positive and negative test cases to verify positive and negative behavior of code: 1. Positive: A positive test case uses valid inputs within the governor limits to verify that the code behaves as expected. 2. Negative: A negative test case uses one or more invalid inputs or exceeds governor limits to verify that the code doesn't allow normal processing in such conditions

How can you store an attachment in an Apex variable?

Use Blob variable

Use cases for classes

Web services Email services Complex validation over multiple objects Complex business processes that are not supported by workflow Custom transactional logic Batch operations

Types of events for Aura components

Aura components support two types of events, namely component events and application events 1. Component events are used for handling events in the containment hierarchy 2. Application events allow handling events at the application-level.

Which types of flows can be used with the external objects?

Autolaunched and screen flows

Which DML operations result in the execution of events in the Save Order of execution?

Insert, update and upsert

Exception Methods - Error Cause

The getCause method returns the cause of the exception as an exception object.

Exception Methods - Line Number

The getLineNumber method returns the line number of the exception

Exception Methods - Error Type

The getTypeName method returns the type of exception.

SOQL - Using the Polymorphic Object

The instanceof method can be used to determine the object type of a polymorphic field. Before the object can be used or passed to a method, for example, it must first be assigned to a variable of the appropriate type.

Invoking Apex from Flow using Process.Plugin - 2

The interface supports three top-level classes: 1. PROCESS.PLUGINREQUEST CLASS: Passes input parameters to the flow 2. PROCESS.PLUGINRESULT CLASS: Returns output parameters from the class 3. PROCESS.PLUGINDESCRIBERESULT: Passes input parameters from the flow to the class Note: Salesforce recommends using @InvocableMethod annotation instead of the Process.Plugin interface due to its more advanced capabilities over the interface such as being able to be referenced from flows, processes, and Custom Invocable Actions REST API endpoint, and support for all data types and bulk operations.

Which method can be used to check whether an object can be created by the current user?

The isCreateable() method

A Lightning web component called leaveRequest is being used for submitting leave requests and provides a section in which only managers can access for reviewing and approving or rejecting the requests accordingly. Another Lightning web component called leaveCalendar is used for loading a calendar that displays leave applications that have been approved by the managers. The developer would like the calendar data to be automatically updated whenever a manager has approved a leave request so that the calendar always show real-time information.

The leaveRequest component can be updated to fire a CustomEventinstance named 'leaveUpdate', for example, and contain details of the leave request. In addition, the leaveCalendar component needs to be modified to handle the custom event. It can either use available data included in the fired event if suitable, or it can reload the calendar upon receiving the event to refresh its data.

SOQL ORDER BY

The optional ORDER BY clause of a SOQL query can be used to control the order of the query results. Example: SELECT Id, Name FROM Account ORDERBY Name ASC NULLS FIRST

Exception Methods - getMessage

getMessage method can be used to obtain the error messageto be displayed to the user

Batchable Apex - Start Method

global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {} The start method is called at the beginning of a batch Apex job. It collects the records or objects to be passed to the interface method execute.

Batchable Apex - Class Declaration

global class CleanUpRecords implements Database.Batchable<sObject> {}

A new custom Apex interface called 'ContactDiscountInterface' needs to be created in an org. The interface needs to be accessible globally and contains a method named 'getContactDiscount' that intakes an Id parameter called 'contactId' and returns a decimal number. Modify the code to meet the requirements. Important question about implementing interfaces with methods

global interface ContactDiscountInterface{ Decimal getContactDiscount(Id ContactId); }

A developer is tasked with creating an Apex class named 'MyExtensibleClass' that needs to be accessed globally and allow extensions or overrides. The class contains a method name 'getLeads' that returns a list of leads, has the same access modifier as the class, and can be overridden by other classes that extend 'MyExtensibleClass.' Modify the code to satisfy the requirements.

global virtual class MyExtensibleClass{ global virtual List<Lead> getLeads(){ return [SELECT Id FROM Lead WHERE Company = 'Universal Container']; } }

Batchable Apex - Execute Method

global void execute(Database.BatchableContext BC, list<P>){} The execute method is called for each batch of records passed to the method. Use this method to do all required processing for each chunk of data: This method takes the following: 1. A reference to the Database.BatchableContext object. 2. A list of sObjects, such as List<sObject>, or a list of parameterized types. If you are using a Database.QueryLocator, the returned list should be used. Batches of records are not guaranteed to execute in the order they are received from the start method

ltng:require

ltng:require enables you to: 1. Load external CSS and JavaScript libraries after you upload them as static resources 2. Use the styles attribute to specify a resource name and CSS file 3. Use the scripts attribute to specify a resource name and JavaScript file.

A developer is creating a queueable Apex class named 'MyOpportunityQueueableClass' that takes a list of opportunities as an argument and moves their stage to 'Closed Won.' The queueable class will need to be publicly accessible, and the QueueableContext variable name is 'context'. Modify the code to define and complete this queueable class.

public class MyOpportunityQueueableClass implements Queueable { public List<Opportunity> oppList ; public MyOpportunityQueueableClass(List<Opportunity> oppList){ this.oppList = oppList ; } public void execute(QueueableContext context) { for(Opportunity opp : oppList){ opp.StageName = 'Closed Won'; } update oppList; } }

What attribute is required to make sure a VF page can be rendered in Lightning?

'lightingStyleSheets' attribute should be set to true in the <apex:page> tag.

Subscribing to Platform Events

An Apex trigger can be used to subscribe to a platform event message; note that in this case, the trigger is written on the event object, not the original object

How can you cause an infinite loop in Apex?

An Apex trigger that has a DML statement which triggers itself will result in an infinite loop and will eventually fail.

What is the standard access modifier for methods and variables?

By default, a method or variable is visible only to the Apex code within the defining class (private).

Can you use SOQL to query for information about scheduled job?

ConTrigger - State AsyncApexJOb - Status

Control Flow Statements

Conditionals and loops allow directing code to perform the necessary execution paths and logic

What platform features are part of the control layer in the MVC model?

Declarative (e.g. workflow and escalation rules) or programmatic (e.g. Visualforce controllers or Apex classes) business logic

Types of Flow - Embedded Appointment Management Flow

Let users schedule, modify, and cancel an appointment.

Indirect Lookup Relationships

Link a child external object to a parent standard or custom object through a custom unique, external ID field

External Lookup Relationships

Link a child standard, custom, or external object to a parent external object using the standard External ID field

How can list custom settings be accessed?

List custom setting data can only be accessed using Apex or API calls

Sample Apex method

Note the notation to use the input variable in the SOQL query.

Recursive trigger

1. A recursive trigger is one that performs an action, such as an update or insert, which invokes itself owing to, say something like an update it performs. 2. Recursion is the process of executing the same task multiple times.

What are the CPU limits in Salesforce?

- 10 seconds for synchronous - 60 seconds for asynchronous

Apex Abstract Class

- Define: public abstract class MyAbstractClass {}. - Use: public class MyChildClass extends MyAbstractClass {}. - Child classes inherit all the methods and properties of the extended class. - Can contain virtual and abstract methods. abstract class is child super-type. - Cannot be initialized. - Class can extend only one abstract class.

Apex Virtual Class

- Define: public virtual class MyVirtualClass {}. - Use: public class MyChildClass extends MyVirtualClass {}. - Child classes inherit all the methods and properties of the extended class. - Can contain only virtual methods. - Virtual class is a child super-type. - Can be initialized. - Class can extend only one virtual class.

Virtual method vs Abstract method

- Virtual method has basic logic, that can be overridden by the child class. - Abstract does not contain logic, and has to be overridden by the child class.

Cast a generic sObject to an Account

// Cast a generic sObject to an Account Account acct = (Account)myGenericSObject; // Now, you can use the dot notation to access fields on Account String name = acct.Name; String phone = acct.Phone;

SOQL INCLUDES and EXCLUDES Operators - Complex Logic ; (semi-colon) - AND , (coma) - OR

1. ('RED;BLUE'): Both RED and BLUE should be selected to match the criteria. 2. ('RED','BLUE'): Either RED or BLUE (or both) should be selected to match the criteria. 3. ('RED;BLUE','GREEN'): Either both RED and BLUE, or GREEN should be selected to match the criteria. 4. ('RED;BLUE','GREEN;YELLOW'): Either both (RED and BLUE), or (GREEN and YELLOW) should be selected to match the criteria.

Ways to declare list of sObjects

1. // Create an empty list of Accounts List<Account> myList = new List<Account>(); 2. Account[] records = new List<Account>{ new Account(Name = 'ACME'), new Account() }; 3. List<Account> records2 = new List<Account>{ new Account(Name = 'ACME'), new Account() };

Change Data Capture

1. A Change Data Capture event, or change event, is a notification that Salesforce sends when a change to a Salesforce record occurs as part of a create, update, delete, or undelete operation 2. The notification includes all new and changed fields, and header fields that contain information about the change 3. Change Data Capture can generate change events for all custom objects defined in your Salesforce org and a subset of standard objects.

The total number of related Interview records should be summarized and displayed on each parent Candidate record. However, all the Interview records should have independent owners.

1. A Lookup Relationship can be utilized for this use case since the ownership of the child records should be independent. 2. An Apex trigger can be defined on the Interview object to calculate and update a custom field on the related Candidate record Develop pseudo code

VF Scenario A VF page is required for the Account detail page. The page should allow a user to specify the new value of certain fields on the account record, such as Industry and Rating, and save the record. However, when the account record is saved, a custom field on the account record named 'Category' should also be changed based on the new values specified by the user.

1. A VF page that uses the standard Account controller can be utilized for this use case. 2. It can make use of a controller extension that overrides the save method of the standard controller. 3. The save method can change the value of the Category field based on the field values of 'Industry' and 'Rating' specified by the user

Component Events

1. A component event is fired from an instance of a component. 2. A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event.

Cross-object formulas

1. A cross-object formula can reference merge fields from a master ("parent") object if an object is on the detail side of a master-detail relationship. 2. A cross-object formula also works with lookup relationships. 3. You can reference fields from objects that are up to 10 relationships away. 4. If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don't have access to that object record.

What is a custom controller?

1. A custom controller is an Apex class that uses the default, no-argument constructor for the outer, top-level class. 2. You cannot create a custom controller constructor that includes parameters. 3. Custom controllers run in system mode by default; choose whether a custom controller respects a user's organization-wide defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition.

Flow vs. Orchestrator

1. A flow automates simple to complex business process by collecting data and triggering actions like record updates, sending email, record creation among many others in a Salesforce org or an external system. Flows are record-centric. 2. An orchestration combines and coordinates a series of flows to create advanced and automated business processes. Orchestrations are user-centric.

What are important points for Einstein Next Best Action?

1. A flow must be created, which is invoked when a recommendation is accepted 2. SFDC recommends using Flow Builder to build a strategy using the Recommendation Strategy flow type and define which recommendations to load or make available to the user based on specific criteria 3. Strategy Builder can also be used to build recommendations 4. Recommendations are loaded via the Einstein Next Best Action component

@future method

1. A future method runs in the background, asynchronously. 2. You can call a future method for executing long-running operations, such as callouts to external Web services or any operation you'd like to run in its own thread, on its own time. 3. You can also use future methods to isolate DML operations on different sObject types to prevent the mixed DML error. 4. Each future method is queued and executes when system resources become available. That way, the execution of your code doesn't have to wait for the completion of a long-running operation. 5. A benefit of using future methods is that some governor limits are higher, such as SOQL query limits and heap size limits.

Best Practices for Apex Classes & Triggers - USE A BULKIFIED HELPER CLASS

1. A helper class that is designed to process records in bulk should contain the logic of the required operations. 2. Methods of the helper class can be invoked to perform specific operations in the trigger 3. The helper methods should be written to handle collections of records, such as an array, list or set, instead of individual records.

Apex Non Primitive Data Types - Collection - List

1. A list is an ordered, indexed (zero-based) collection of primitives or non-primitives 2. A list can be declared using the List keyword followed by the primitive data type, sObject, nested list, map, or set within <> characters. List methods such as add(),get(), remove(), and set() can be used to manage elements in a list. 3. Array notation such as myListItems[0] can be used to retrieve the first element in a list.

Apex Non Primitive Data Types - Collection - Map

1. A map can be declared using the Map keyword followed by the data types of the key and value within <> characters 2. Key-value pairs can be populated by specifying the key and then the value for that key using the => operator within curly brace({}) syntax 3. Maps can be populated directly from results returned by a SOQL query. In this method, the map key should be declared with an ID or String data type, and the map value should be declared as an sObject

Events

1. A notification by the browser regarding an action. Browser events are handled by client-side JavaScript controllers, as shown in the previous example. 2. A browser event is not the same as a framework component event or application event, which you can create and fire in a JavaScript controller to communicate data between components. 3. For example, you can wire up the click event of a checkbox to a client-side controller, which fires a component event to communicate relevant data to a parent component. 4. Another type of event, known as a system event, is fired automatically by the framework during its lifecycle, such as during component initialization, change of an attribute value, and rendering. Components can handle a system event by registering the event in the component markup.

Einstein Next Best Action

1. A recommendation can only invoke one and the same flow when it is either accepted or rejected by the user 2. By default, a recommendation only launches the flow when it is accepted 3. To also launch a flow when it is rejected, a Decision element is added to the flow that specifically uses an 'isRecommendedAccepted' boolean variable for determining whether the recommendation that launched was approved or rejected and the perform the necessary logic accordingly

Record-Trigger Flow Triggers

1. A record is created 2. A record is updated 3. A record is created or updated 4. A record is deleted

Apex Non Primitive Data Types - Collection - Set

1. A set is an unordered collection of unique elements and cannot contain duplicate values. 2. A set can be declared using the Set keyword followed by the name of the primitive data type within <> characters. 3. Set methods such as add() and remove() can be used to manage elements in a set.

Apex Scenario Cosmic Service Solutions would like to implement a business process that creates or updates a log record every time a case is created or updated. 'Log' is a custom object that is unrelated to the Case object. Each log record should contain detailed information about the case.

1. A single Apex trigger that contains both 'after insert' and 'after update' events can be defined for this use case. 2. Since 'Log' is an unrelated custom object, a process cannot be used to update a log record when a case is updated. 3. While defining the trigger, the 'isInsert' and 'isUpdate' context variables should be used to determine whether case records are being inserted or updated. 3. Lists can be defined to insert new log records and update existing log records. 4. Two 'for' loops can be used to specify new field values for each context. 5. For the 'isUpdate' context, a SOQL query can be used outside the 'for' loop to obtain the log records that should be updated. 6. Any DML operations should be performed outside the loop. 7. Note that an after-save record-triggered flow can also be used in this scenario. A trigger is used here to illustrate code best practices.

Apex Non Primitive Data Types - Collection - sObjects

1. A specifics Object variable can be declared using the SOAP API name of the object and the new operator. 2. A generic sObject variable can also be declared using the new operator.

VF - Standard Controller

1. A standard controller exists for every standard and custom object which can be queried using the Force.com API. 2. Standard controllers contain the functionality and logic that are used for standard Salesforce pages

VF Scenario A developer is working on a VF page that uses the Account standard controller. The page should display the name and title of all the contacts related to a particular account in a table.

1. A table of data can be displayed using an iteration component such as the <apex:pageBlockTable>. 2. The value attribute can be used to set the list of records. 3. The var attribute can be used to assign each record in the list to a variable. The component can be used to retrieve the name and title of each contact.

Class Variables

1. Access Modifiers: Access modifiers such as public/private/protected/global can be used to define the accessibility. By default, variables are private if not specified. 2. Optional Keywords: Optionally, final and static keywords can be used for the variable 3. Null as Default: A variable can be assigned a value when declaring. If not assigned a value, its default value will be null.

What are characteristics of invocable methods?

1. Access modified: public or global 2. Needs to be static and 3. Needs to accept a collection 4. May return a value

Using setter methods

1. Access modifier: They should have at least public access level so that the Visualforce framework can access them 2. Method structure: A setter method hasone input parameter and does not return anything 3. Not always necessary: It's not always necessary to include a setter method to pass values into a controller

Consider the following when invoking a flow from Apex.

1. Active flow: In order for Apex code to successfully call a flow, the status of the flow must be active. 2. Dynamic call: A flow can be called from Apex dynamically. Meaning, the flow is not fixed or hardcoded in Apex, which allows the flow to invoke to be determined only at run-time.

A developer created a Lightning web component called statusComponent to be inserted into the Account record page.

1. Add <isExposed> true</isExposed> to the statusComponent.js-meta xml file. 2. Add <target> lighting _RecordPage </target> to the statusComponent.js-meta xml file.

Information about Apex Jobs

1. All completed Apex jobs, irrespective of the nature of the job, can be viewed by navigating to 'Apex Jobs' in Set Up 2. Scheduled Jobs can be seen 'Schedule Jobs' (jobs that already ran or will run in the future) 3. There is no 'Jobs' option under Set Up 4. Monitoring the Apex Flex Queue: use the Apex Flex Queue page to view and reorder all batch jobs that have a status of Holding. Or reorder your batch jobs programmatically using Apex code (future jobs do not appear here, only the ones with status of Holding)

Record-Triggered Flow Entry Conditions

1. All conditions are met (AND) 2. Any condition is met (OR) 3. Custom condition logic is met (AND/OR) 4. Formula evaluates to True

Interface Scenario 1 (Inbound emails with attachments) The customer service department receives emails from their website users containing attachments such as images or documents. A multiple-step process is involved where the agents have to manually download and then upload the attachments to the related cases in their org. The department is asking if there is a way to improve the process.

1. An Apex class can be built that extends the Messaging.InboundEmailHandler interface 2. This enables the class to handle inbound email messages and store the contents and attachments of an email message in an object called InboundEmail. 2. Having access to this object through the class enables automating the upload process by retrieving any email attachment and uploading to the related case such that it skips the entire manual work

Apex Scenario A growing logistics company handles shipping and delivery services for a several premium clients. As all their orders are stored and tracked in their CRM, they asked a Salesforce consultant if it was possible to make available a web service that would return information and status of orders as one of the initial capabilities. This allows their clients to integrate with their system and be able to automate order status enquiries among other possibilities.

1. An Apex class can be exposed as a web service. In order to achieve this, the class must be defined as global and its methods as global static. 2. The class, for example, is annotated with @RestResource(urlMapping='/OrderStatus/')*. 3. A method annotated with *@HttpGet* can be used to fetch and return an order based on an ID passed via the parameter

Batch vs. Scheduled Apex

1. An Apex class that implements the Database.Batchable interface is required to use batch Apex 2. To schedule an Apex class, it must implement the Schedulable interface.

Subscribing an Aura Component to a Platform Event

1. An Aura component can be created to subscribe to a platform event. The lightning:empApi component, which enables listening to event messages, requires to be added to the Aura component markup. 2. The lightning:empApi subscribe and unsubscribe methods are then called in the client controller.

Switch Statement

1. An expression can be of the type Integer, Long, sObject, String, or Enum. It is also possible to switch on the result of a method call instead of a variable expression. 2. Each when value must be unique, and it is possible for a value to be null. 3 A when block can use multiple, comma-separated literal and enum values, but not both simultaneously. 4. Only one sObject type can be used per when block.

With flow orchestrator, what interactive and background steps?

1. An interactive step is assigned to a user, group, or queue as it requires user interaction 2. A background step launches an auto-launched flow and requires no user interaction.

Considerations related to sharing modes

1. Anonymous Block: Anonymous code is always executed using the full permissions of the current user regardless of the sharing mode defined in a class 2. Omitted Sharing: If no sharing mode is declared in a class, it will not enforce sharing rules unless it is called from a class that enforces sharing rules. 3. Omitted vs. Inherited: If a class with no specified sharing mode is used as the entry point to an Apex transaction, it will run as without sharing. If a class with inherited sharing is used, it will run as with sharing. 4. Lighting Components: Apex classes used by custom Lightning components respect sharing rules by default What is an entry point to Apex transaction? Need to study this slide

More information on the Object variable

1. Any data type that is supported in Apex. 2. Apex supports primitive data types (such as Integer), user-defined custom classes, the sObject generic type, or an sObject specific type (such as Account). 3. All Apex data types inherit from Object.

Data Access Control

1. Apex Classes do not enforce CRUD (system context) 2. Visualforce Pages do enforce CRUD (user context) 3. Apex classes do not enforce FLS (system context) 4. Visualforce pages do enforce FLS (user context); Exception: de-referenced fields: • {!Contact.Email} = yes • {!contactEmail} = NO

Record access with Apex and VF

1. Apex classes do not enforce sharing (by default due to system context) 2. Visualforce pages do not enforce sharing (Rely on controller for record access) - exception: standard controllers enforce sharing

Rolling Back Transactions and Savepoints

1. Apex supports rolling back transactions. You can generate a savepoint which sets a point in the request that corresponds to a state in the database. 2. Any DML statement that occurs after the savepoint can be discarded and the database can be restored to the same initial condition.

Sub-classes

1. Apex supports subclasses, allowing you to create a class that extends another class. 2. The subclass inherits all the functionality of that parent class. 3. It can also have additional methods and member variables, and can override the behavior of existing parent class methods.

What type of Aura Component bundles possible?

1. Application (*.app) 2. Component (*cmp)

Running an Orchestration

1. Async process: Processing background steps asynchronously can help prevent orchestration errors. This is option is best used when associated flows makes external callout or contains Pause element. 2. Cancel and orchestration: Processing background steps asynchronously can help prevent orchestration errors. This is option is best used when associated flows makes external callout or contains Pause element. 3. Paused orchestration: The orchestration run ID is accessible through the $Orchestration.Instance system variable. This can be utilized to fire a Flow Orchestration Event platform event and wake up the associated paused orchestration run.

Aura Components

1. Aura components are the self-contained and reusable units of an app. They represent a reusable section of the UI, and can range in granularity from a single line of text to an entire app. 2. The framework includes a set of prebuilt components. For example, components that come with the Lightning Design System styling are available in the lightning namespace. These components are also known as the base Lightning components. You can assemble and configure components to form new components in an app. Components are rendered to produce HTML DOM elements within the browser. 3. A component can contain other components, as well as HTML, CSS, JavaScript, or any other Web-enabled code. This enables you to build apps with sophisticated UIs.

Platform Events

1. Based on Event-Driven Architecture which enable apps to communicate inside and outside of Salesforce 2. Platform events are based on the publish/subscribe model and work directly with a message bus which handles the queue of incoming events and processes listening for them 3. This is built in real time integration patterns in the Salesforce Platform which helps to reduce point-to-point integration

Batch Apex

1. Batch Apex is used to run large jobs (think thousands or millions of records!) that would exceed normal processing limits. 2. Using Batch Apex, you can process records asynchronously in batches (hence the name, "Batch Apex") to stay within platform limits. If you have a lot of records to process, for example, data cleansing or archiving, Batch Apex is probably your best solution. 3. If one batch fails to process successfully, all other successful batch transactions aren't rolled back.

Use sObjects

1. Because Apex is tightly integrated with the database, you can access Salesforce records and their fields directly from Apex. \ 2. Every record in Salesforce is natively represented as an sObject in Apex. 3. For example, the Acme account record corresponds to an Account sObject in Apex.

Queueable Versus Future Apex

1. Because queueable methods are functionally equivalent to future methods, most of the time you'll probably want to use queueable instead of future methods. 2. Another reason to use future methods instead of queueable is when your functionality is sometimes executed synchronously, and sometimes asynchronously.

What's one requirement before creating an Apex email service?

1. Before creating email services, create Apex classes that implement the Messaging.InboundEmailHandler interface. global class myHandler implements Messaging.InboundEmailHandler {}

Techniques to Prevent SOQL Injection

1. Bind variables with static queris: An input can be enforced to be treated as a variable and not an executable part of the query. 2. Typecast variables: Typecasting is where variables are casted according to their respective data types (e.g., Boolean, Integer) to intentionally throw exceptions when unexpected data types are encountered. 3. Escaping single quotes: An escape character can be added to all single quotation characters using String.escapeSingleQuotes() to ensure that the strings are not treated as commands. 4. Allowlist variables: If possible user input values are known, the input value should be checked against that defined list, or an allowlist. Also, a NOT NULL check should be avoided. 5. Sanitize input: Also known as restricted list, this approach involves removing potential bad characters from user input.

Exception Handling in Apex - Types of Exceptions

1. Built-in 2. Custom

Getter Methods - get info from Apex class to VF page Setter Methods - get info from VF page to Apex class

1. Called before action methods: In a VF controller, they are executed automatically before action methods 2. No setter methods required: A setter method may not be always required to pass values into a controller. If a VF component is bound to an sObject that is stored in a controller, the sObject's fields are automatically set if changed by the user, as long as the sObject is saved by a corresponding action method. For example, <apex:inputField value="{!lead.company}" />.

Which two characteristics are true for Aura component events?

1. Calling event, stopPropagation ( ) may or may not stop the event propagation based of the current propagation phase. 2. The event propagates to every owner in the containment hierarchy.

Use Cases for Future Methods

1. Callouts to external Web services: if you are making callouts from a trigger or after performing a DML operation, you must use a future or queueable method. A callout in a trigger would hold the database connection open for the lifetime of the callout and that is a "no-no" in a multitenant environment. 2. Operations you want to run in their own thread: when time permits such as some sort of resource-intensive calculation or processing of records. 3. Isolating DML operations on different sObject types to prevent the mixed DML error. This is somewhat of an edge case, but you may occasionally run across this issue.

SOQL Relationship Queries - Examples

1. Child to Parent Example: SELECT Id, Name, Account.Name FROM Contact WHEREAccount.Rating = 'Cold' 2. Parent to Child Example: SELECT Name, (SELECT LastName FROM Contacts) FROM Account Note: the the S

Apex Class Definition

1. Class Name: A class is defined using the required class keyword and then followed by the desired name of the class 2. Access Modifier: A class is required to have an access modifier (eg. public, global) except for inner classes. 3. Extend/Implement: A class is allowed to extend another class and/or implement one or more interfaces. 4. Definition Modifier: Using definition modifiers such as virtual and abstract are not required in a class definition (virtual/abstract) 5. Sharing Mode: The sharing mode of a class can be defined to determine how it should handle data access restrictions

From the MVC, what what are the two "controller" models in Salesforce?

1. Client-side (JavaScript): used for client-side operations 2. Server-side (Apex): used to perform database operations; The JavaScript controller is used to call methods in the Apex controller.

Lightning Web Components Considerations

1. Co-existence: Lightning web components and Aura components can coexist on the same page. 2. Look the same: Both types of components will appear as Lightning components and indistinguishable to the admin and end user 3. Child components: Although a Lightning web component can contain another Lightning web component, it cannot contain an Aura component. 4. Load Methods: The methods loadScript and loadStyle that are available through the platformResourceLoader module can be used to load Javascript and CSS files respectively. 5. Referencing files: Unlike Aura components, referencing of Javascript and CSS files in Lightning web components is handled in the client controller instead of the template or component markup

What are two ways to call a web service?

1. Configuration of outbound message 2. Custom Web services (Apex)

VF Page Controllers

1. Controllers, which are essentially Apex classes, are used to provide pages with data and business logic that defines how to access data. 2. Salesforce provides standard controllers for every standard and custom object. 3. The standardControllerattribute is added to the <apex:page>tag and assigned the name of the standard or custom object.

Flow Iterations (similar to triggers)

1. Create Record: Before Save, After Save 2. Update Record: Before Save, After Save 3. Delete Record: Before Delete

Create Custom Component Events

1. Create a custom component event using the <aura:event> tag in a .evt resource. Events can contain attributes that can be set before the event is fired and read when the event is handled. 2. Use type="COMPONENT" in the <aura:event> tag for a component event. For example, this c:compEvent component event has one attribute with a name of message. 3. The component that fires an event can set the event's data. To set the attribute values, call event.setParam() or event.setParams(). A parameter name set in the event must match the name attribute of an <aura:attribute> in the event

What are two considerations for custom Apex Exception classes?

1. Custom Exception class names must end with the word 'Exception'. 2. Custom Exception classes must extend the base Exception class.

VF - Custom Controller

1. Custom controllers and controller extensions can be written to override existing functionality, customize navigation, use callouts and web services, or have finer control over information access. 2. Built from scratch: A custom controller implements logic without leveraging a standard controller nor build off its functionality 3. Runs on system mode: Custom controllers can be used to run VF pages entirely in system mode without enforcing permissions and field-level security of the current user.

What can a custom tab display in Salesforce?

1. Custom object 2. Web tab: Web tabs are custom tabs that display web content or applications 3. VF page, 4. Lightning Component 5. Lightning page

About Transactions

1. DML operations execute within a transaction. 2. All DML operations in a transaction either complete successfully, or if an error occurs in one operation, the entire transaction is rolled back and no data is committed to the database. 3. The boundary of a transaction can be a trigger, a class method, an anonymous block of code, an Apex page, or a custom Web service method. For example, if a trigger or class creates two accounts and updates one contact, and the contact update fails because of a validation rule failure, the entire transaction rolls back and none of the accounts are persisted in Salesforce.

VF pages and Getter/Setter

1. DML statements can't be used in getter methods (and constructor methods) 2. Getter and setter methods cannot be annotated with @future

Data Import - Preventing Duplicates

1. Data Import Wizard will prevent duplicates by uploading records according to account name and site, contact email address, or lead email address 2. Data Loader can only detect duplicate records on unique fields such as the Salesforce record Id or External-Unique Id

Workflow and data import

1. Data import wizard: Can bypass workflow rules and processes 2. Data Loader: Cannot bypass workflow rules and processes

Debug an Orchestration

1. Debug details: Debug information for orchestration includes details similar to flow debug logs and details on milestones for orchestrations, stages, steps, and work items details. 2. In-Progress Orchestration: The "Debug Orchestration" action is available for every in-progress runs. In-progress orchestrations are found in the Orchestration Runs list view. 3. Failed Orchestration: Failed orchestrations can be reviewed and debugged from the Paused and Failed Flow Interviews page in Setup

How can you execute test methods?

1. Developer Console 2. SOAP API 3. VS Code

Events Anti-Patterns

1. Don't Fire an Event in a Renderer: Firing an event in a renderer can cause an infinite rendering loop. 2. Don't Use onclick and ontouchend Events: You can't use different actions for onclick and ontouchend events in a component. The framework translates touch-tap events into clicks and activates any onclick handlers that are present.

Best practices for running within the Apex heap size

1. Don't use class level variables to store a large amounts of data. 2. Utilize SOQL For Loops to iterate and process data from large queries. 3. Construct methods and loops that allow variables to go out of scope as soon as they are no longer needed.

StartTest and stopTest

1. Each test method executes the delete DML operation within Test.startTest/Test.stopTest blocks. Each test method can have only one such block. 2. All code running within this block is assigns a new set of governor limits separate from the other code in the test.

Trace flags

1. Each trace flag can only be assigned to one debug level 2. Trace flags can be configured in the Developer Console and Salesforce UI 3. A trace flag includes a specific debug level, a start time, end time, and log type 4. Trace flags are assigned debug levels to active debug logs for users, Apex classes, and triggers 5. The trace flag's log type specifies the entity you're tracing.

Future methods - best practices

1. Ensure that future methods execute as fast as possible. 2. If using Web service callouts, try to bundle all callouts together from the same future method, rather than using a separate future method for each callout. 3. Conduct thorough testing at scale. Test that a trigger enqueuing the @future calls is able to handle a trigger collection of 200 records. This helps determine if delays may occur given the design at current and future volumes. 4. Consider using Batch Apex instead of future methods to process large number of records asynchronously (LDV). This is more efficient than creating a future request for each record.

Apex Non Primitive Data Types - Collection - Enum

1. Enum is a data type that specifies a set of constants 2. Enum variables can be declared by using the enum keyword and curly braces to list the possible values

Bubble - Here's the sequence of component event propagation.

1. Event fired—A component event is fired. 2. Capture phase—The framework executes the capture phase from the application root to the source component until all components are traversed. Any handling event can stop propagation by calling stopPropagation() on the event. 3. Bubble phase—The framework executes the bubble phase from the source component to the application root until all components are traversed or stopPropagation() is called.

Application Event Propagation - Default

1. Event handlers are invoked in a non-deterministic order from the root node through its subtree. The default phase doesn't have the same propagation rules related to component hierarchy as the capture and bubble phases. The default phase can be useful for handling application events that affect components in different sub-trees of your app. 2. If the event's propagation wasn't stopped in a previous phase, the root node defaults to the application root. If the event's propagation was stopped in a previous phase, the root node is set to the component whose handler invoked event.stopPropagation().

Update Related Records

1. Fields on related records can't be updated with the same call to the DML operation and require a separate DML call. 2. For example, if inserting a new contact, you can specify the contact's related account record by setting the value of the AccountId field. 3. However, you can't change the account's name without updating the account itself with a separate DML call. 4. Similarly, when updating a contact, if you also want to update the contact's related account, you must make two DML calls. The following example updates a contact and its related account using two update statements.

In flow, what does the 'Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed' checkbox do?

1. Finally, you can use a record-triggered flow to integrate with an external system and update external objects—without writing any code. 2. Add an asynchronous path that runs after the original transaction for the triggering record is successfully committed 3. Now your record-triggered flows can perform actions that were previously limited by transaction boundaries 4. For example, use an asynchronous path to post a message to Slack, update a record in Heroku, or place an order using a third-party fulfillment system. 5. Both asynchronous and scheduled paths are subject to the same asynchronous per-transaction Apex limits.

Invoking flow from Apex

1. Flow.Interview.FlowName(params)start(); 2.Flow.Interview.createInterview(\'[FlowName]\',params).start

Which declarative tools can send outbound messages?

1. Flows 2. Workflows 3. Approval processes

Apex and Components Interaction

1. Flows can invoke Apex, and Apex can also invoke flows 2. Aura or Lightning Web components can execute Apex methods that have @AuraEnabled annotations. 3. Flow and VF Pages loaded in standard Lightning components can call invocable methods and controller methods respectively.

What is a Salesforce Function?

1. Functions allows developers to write code that implements their business logic, which can then be assembled as building blocks in Flows or integrated with Lightning Web Components. 2. Functions let you program in industry-standard languages, such as Node.js and Java. 3. They allow execution of programming logic that is developed in another language 4. A function is created locally and then deployed to a serverless computing environment that is connected to a Salesforce org using Salesforce CLI 5. Functions are invoked using Apex 6. They can also be used in flows through invocable methods on in LWCs through Aura-enabled methods

Future Apex

1. Future Apex is used to run processes in a separate thread, at a later time when system resources become available. 2. When using synchronous processing, all method calls are made from the same thread that is executing the Apex code, and no additional processing can occur until the process is complete. 3. You can use future methods for any operation you'd like to run asynchronously in its own thread. 4. This provides the benefits of not blocking the user from performing other operations and providing higher governor and execution limits for the process.

Characteristics of future methods

1. Future methods must be static methods and can only return a void type. 2. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. 3. Notably, future methods can't take standard or custom objects as arguments. 3. A common pattern is to pass the method a List of record IDs that you want to process asynchronously.

Using Get/Set with variables: public Integer ecoRating { get { return ecoRating; } set { ecoRating = value; if (ecoRating < 0) ecoRating =0; } }

1. Get block: code that should run when the value is retrieved 2. Set block: code that should run when the value is set

Getter Methods

1. Getter methods return values from a controller. 2. Every value that is calculated by a controller and displayed in a page must have a corresponding getter method, including any Boolean variables. 3. For example, in the sample page in Build a Custom Controller, the controller includes a getAccount method. This method allows the page markup to reference the account member variable in the controller class with {! } notation. 4. The value parameter of the <apex:inputField> tag uses this notation to access the account, and dot notation to display the account's name. Getter methods must always be named getVariable. Apex Controller --> Getter --> VF Page

Apex Scenario There was an issue with a data entry procedure in a data mining company. Now, a script needs to be created and run by a developer that validates and corrects data accordingly on an org that contains a massive number of records. If the governor limits are reached during this process, all the changes unfortunately will be rolled back. How can a rollback be avoided?

1. Governor limit exceptions cannot be handled. When an unhandled exception occurs in an Apex transaction, any changes made are rolled back. 2. To prevent the roll back, the limit exception must not be invoked. 3. To prevent the exception from getting invoked, Limit methods such as Limits.getDMLStatements()and Limits.getLimitDMLStatements(), for example, can be used to determine the remaining number of DML statements allowed before actually executing the DML method. 4. If there is no more quota left, Apex can skip executing further DML statements

Which two are best practices when it comes to component and application event handling?

1. Handle low-level events in the event handler and re-fire them as higher-level events. 2. Reuse the event logic in a component bundle, by putting the logic in the helper.

Best Practices for Apex Classes & Triggers - HARDCODING IDS SHOULD BE AVOIDED

1. Hardcoding record Ids is discouraged as there is no guarantee that the Ids will be the same in another environment. 2. If an application with hardcoded record type Ids, for example, is deployed to another org, the application will fail to function properly. 3. The developer name instead can be used when referring to the record type as this is a user-defined field value and not generated by the system.

LWC - Items in the component bundle

1. Helper file - can put functions that can be called by an JavaScript code in a component bundle 2. Component file - contains the markup for the component 3. Controller file - contains functions that are typically called as a result of browser or platform event 4. Design file - exposes attributes of the component that can be modified from an interface, such as Lightning App Builder

How can hierarchy and list custom settings be accessed?

1. Hierarchy: can be accessed in Apex using custom settings methods or in formula fields, validation rules, flows and processes using the $Setup variable 2. List: can only be accessed through Apex or through API calls

Best Practices for Apex Classes & Triggers - USE RELATIONSHIPS TO AVOID QUERIES

1. If Apex code needs to process child records of a parent record, a subquery can be added to an original query that is used for retrieving the parent records. 2. This avoids the need to perform another query when processing parent records and reduces the number of queries that are called in a single transaction.

Apex Scenario A sales company has accumulated hundreds of thousands of inactive Lead records over the years as there was no data maintenance process in place. They have recently hired a Salesforce professional to clean up their CRM. What are some of the considerations when using Apex to perform the clean up regarding governor limits?

1. If Apex runs a SOQL query that potentially returns more than 50,000 records, a governor limit is encountered as SOQL is only allowed to retrieve a maximum of 50,000 records at a time. 2. Updating records in batches is a best practice, and one must also be aware that only up to a total number of 10,000 records can be processed in a single Apex transaction. 3. For example, if in one Apex transaction, a DML update statement is executed on a list which contained 10,000 records, and then a database.emptyRecycleBin() method was also executed that caused it to deleted 1 record or more, a limit exception will be encountered. 4. The developer can consider using Batch Apex which would be most suitable for the job

DML Statement Exceptions

1. If a DML operation fails, it returns an exception of type DmlException. 2. You can catch exceptions in your code to handle error conditions. 3. This example produces a DmlException because it attempts to insert an account without the required Name field. The exception is caught in the catch block.

VF pages and web services

1. If a class includes a web service method, it must be defined as global 2. Although the initial web service access is controlled by the user's profile, the web service eventually runs in system mode. This could lead to inadvertent exposure of sensitive data

What additional field changes may impact Apex?

1. If a new value is added to a picklist field, the logic used in Apex code may need to be updated 2. Modifying the length or decimal place of a field may cause data loss 3. Although a field that is used in Apex code can be made required, it can cause an exception. If the value of a required field is not specified, it causes an error. 4. If a roll-up summary field is modified, it can change the output of any Apex code that uses the field

Restricting picklist values

1. If a picklist field uses a global picklist value set, the field always has restricted values 2. if a picklist field uses local values, the field can or cannot have restricted values

Best Practices for Apex Classes & Triggers - USE SOQL FOR LOOP

1. If a query returns a large volume of data and cause the transaction to exceed the heap limit, a SOQL for loop should be used to process multiple batches of the resulting records through the use of internal calls to query and queryMore. 2. When a SOQL query is defined in a for loop definition, the query results are chunked into batches of 200 records, and the for loop logic can be designed to handle those individual batches

Considerations for Overriding Standard Buttons

1. If you override a standard button in Salesforce, that button is still available in Connect Offline, but it retains its original behavior. 2. The View standard button refers to all links in Salesforce that display the detail page for a record; overriding the View standard button reroutes all these links. 3. You can override buttons on the detail page but not the edit page of a record. 4. You can only override these standard buttons: New, View, Edit, and Delete 5. Different override behaviors for Salesforce Classic, Lightning Experience, and Mobile can be set

Which three steps allow a custom SVG to be included in a Lightning web component?

1. Import the static resource and provide a getter for it in JavaScript 2. Upload the SVG as a static resource 3. Reference the getter in the HTML template.

Asynchronous Apex

1. In a nutshell, asynchronous Apex is used to run processes in a separate thread, at a later time.

What options are available with Data Loader?

1. Insert 2. Update 3. Upsert 4. Delete 5. Hard Delete 6. Export 7. Export All

What are the two types of inheritance in Apex?

1. Interface: does not have the body of the method; the class defines the method logic; use implements keyword 2. Virtual class; use the extends keyword

Aura component interfaces

1. Interfaces define a component's shape by defining attributes, events, or methods that any implementing component contains. 2. To use an interface, a component must implement it. 3. An interface can't be used directly in markup. 4. An interface starts with the <aura:interface> tag, and can contain only these tags: <aura:attribute>

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.

1. Invocable methods and invocable variables support sObject types. 2. 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. 3. 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.

@InvocableMethod

1. Invocable methods are called with REST API and used to invoke a single Apex method. Invocable methods have dynamic input and output values and support describe calls. 2. The invocable method must be static and public or global, and its class must be an outer class. 3. Only one method in a class can have the InvocableMethod annotation. 4. Other annotations can't be used with the InvocableMethod annotation.

@INVOCABLEMETHOD Annotation

1. Invocable methods are called with REST API and used to invoke a single Apex method. Invocable methods have dynamic input and output values and support describe calls. 2. The invocable method must be static and public or global, and its class must be an outer class. 3. Only one method in a class can have the InvocableMethod annotation. 4. Other annotations can't be used with the InvocableMethod annotation. 5. You can use invocable methods in packages, but after you add an invocable method you can't remove it from later versions of the package. 6. Public invocable methods can be referred to by flows and processes within the managed package. 7. Global invocable methods can be referred to anywhere in the subscriber org. Only global invocable methods appear in Flow Builder and Process Builder in the subscriber org.

For methods to be invocable, what to do they need?

1. Invocable methods must be static and either public or global 2. An invocable method can have at most one input parameter and the @InvocableVariable annotation can be used to identify class variables used as input or output parameter. 3. Classes with the @InvocableMethod annotation will be available to flows, processes, and the REST API

CRUD and Field-Level Security (FLS) - Ligthning Components

1. Lightning components don't automatically enforce CRUD and FLS when you reference objects or retrieve the objects from an Apex controller. 2. This means that the framework continues to display records and fields for which users don't have CRUD access and FLS visibility. 3. You must manually enforce CRUD and FLS in your Apex controllers.

VF pages and security

1. Like most Apex classes, controllers and extensions run in system mode. The with sharing keyword should be used to ensure security policies if needed. 2. Controllers and extensions are generally declared public

Asynchronous Paths in Record-Triggered Flows - An asynchronous path can be used to perform an operation that is executed asynchronously and does not impact the execution of the original triggered transaction

1. Long-running: A process that requires a long time to complete can be executed asynchronously. 2. Background-running: Asynchronous operations run on its own time in the background 3. Mixed DML error: A mixed DML error can be avoided by running an operation asynchronously.

Using Getter Methods

1. Method structure: A getter method has no input parameters, but it returns an object 2. Naming convention: In getIdentifier, the Identifier is the name for the records or primitive values returned by the method. For example, getScore() or getProjectManagers() 3. Access Modifier: Getter methods should have at least public access level so that the Visualforce framework can access them. 4. Calling the method: The results of a getter method can be displayed by using the name of the getter method without the get prefix in an expression on the Visualforce page. For example, {!Score} or {!ProjectManagers}. 5. Accessing Data: A getter method is required to access data from the Visualforce page controller

Which methods in custom controllers allow the use of the @future annotation?

1. Methods containing DML statements 2. Methods containing web service callouts

What does the destructiveChanges.xml file specify?

1. Must specify the name of the metadata component member 2. Must specify the name of the metadata component type

What additional configuration is required to support custom lightning components?

1. My Domain: MyDomain must be deployed in the org. When deployed, references and links to Lightning resources will be in the base URL format https://mydomain.lightning.force.com. 2. Page Support: The custom Lightning component must be configured to be available in Lightning App Builder as well as to support the necessary Lightning page types.

When debugging flows, which statements cannot be rolled back?

1. Non-DML statements (such as HTTP requests) 2. Asynchronous DML statements 3. Actions

Queueable Apex - Additional Benefits

1. Non-primitive types: Your Queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types. Those objects can be accessed when the job executes. 2. Monitoring: When you submit your job by invoking the System.enqueueJob() method, the method returns the ID of the AsyncApexJob record. You can use this ID to identify your job and monitor its progress, either through the Salesforce user interface in the Apex Jobs page, or programmatically by querying your record from AsyncApexJob. 3. Chaining jobs: You can chain one job to another job by starting a second job from a running job. Chaining jobs is useful if you need to do some sequential processing.

Why Async Apex?

1. One of the main benefits of running asynchronous Apex is higher governor and execution limits. For example, the number of SOQL queries is doubled from 100 to 200 queries when using asynchronous calls. 2. The total heap size and maximum CPU time are similarly larger for asynchronous calls. 3. Not only do you get higher limits with async, but also those governor limits are independent of the limits in the synchronous request that queued the async request initially.

Batch Apex - Best Practices

1. Only use Batch Apex if you have more than one batch of records. If you don't have enough records to run more than one batch, you are probably better off using Queueable Apex. 2. Tune any SOQL query to gather the records to execute as quickly as possible. 3. Minimize the number of asynchronous requests created to minimize the chance of delays. 4. Use extreme care if you are planning to invoke a batch job from a trigger. You must be able to guarantee that the trigger won't add more batch jobs than the limit.

Orchestration Order and History

1. Orchestration Order: The order in which record-triggered orchestrations are executed can be controlled using the Flow Trigger Explorer. 2. Orchestration History: When an orchestration runs, it logs milestones. Likewise, when it is canceled; a stage or step is discontinued; an orchestration, stage, or step encountered an error; or a work item is reassigned. Milestones provide statuses of the orchestration run, stages, steps, and work items which helps in testing and debugging orchestrations.

Access modifiers need to be specified on outer classes, they are not required in inner classes

1. Outer Classes: It is mandatory to specify one of the access modifiers (such as public or global) when declaring an outer class, or also known as a top-level class 2. Inner Classes: It is not mandatory to specify an access modifier when declaring inner classes; the default access for inner classes is private, meaning if the access modifier is not specified, it is considered private.

VF Scenario The sales director of Cosmic Grocery would like a developer to work on a VF page for the Contact detail page that displays information like the type of account and the name of the owner of the account associated with a particular contact

1. The developer can build a VF page that uses the Contact standard controller 2. In the VF page markup, merge field syntax can be used to retrieve data from the contact's parent account. 3. It is possible to traverse up to five levels of child-to-parent relationships. For example, the following merge field syntax can be utilized to retrieve the First Name of the account owner: {!contact.Account.Owner.FirstName}

Difference between Platform Events and Change Data Capture (CDC)

1. Platform Event is based on Event-Driven Architecture which enable apps to communicate inside and outside of Salesforce. Platform events are based on the publish/subscribe model and work directly with a message bus which handles the queue of incoming events and processes listening for them. This is built in real time integration patterns in the Salesforce Platform which helps to reduce point-to-point integration. 2. Change Data Capture event, or change event, is a notification that Salesforce sends when a change to a Salesforce record occurs as part of a create, update, delete, or undelete operation. The notification includes all new and changed fields, and header fields that contain information about the change. Change Data Capture can generate change events for all custom objects defined in your Salesforce org and a subset of standard objects Notes: a. Simply put, platform events are API level; CDC is database level. b. Platforms events are triggered from API, that can either be Salesforce or other systems that connect/contact Salesforce. API can communicate with all UI (LWC, aura,vf). These are triggered by code, and used by code or config tools. c. Change Data are triggered from database, when a record inside database is changed this can be triggered. d. we don't use scheduled jobs for this anymore, we set CDC for that object, and trigger API request if there is streaming event from CDC.

Difference between Platform Events & Change Data Capture

1. Platforms events are triggered from API, that can either be Salesforce or other systems that connect/contact Salesforce. API can communicate with all UI (LWC, aura,vf). These are triggered by code, and used by code or config tools. 2. Change Data are triggered from database, when a record inside database is changed this can be triggered.

Considerations for Relationship Queries - 1

1. Plural form: The child relationship name in a parent-to-child traversal is the plural form of the child object name. For example, Contacts and OpportunityLineItems. 2. Query syntax: The relationship name for a custom object used in a query must be appended with __r instead of __c. For example, Shipments__r and Agreements__r

Access Modifiers

1. Private: This is the default, and means that the method or variable is accessible only within the Apex class in which it is defined. 2. Public: This means the method or variable can be used by any Apex code in this application or namespace (In Apex, if you want to make something public like it is in Java, you must use the global access modifier) 3. Global: This means the method or variable can be used by any Apex code that has access to the class, not just the Apex code in the same application or namespace; this access modifier must be used for any method that must be referenced outside of the application, either in SOAP API or by other Apex code. 4. Protected: This means that the method or variable is visible to any inner classes in the defining Apex class, and to the classes that extend the defining Apex class.

How do you resolve CPU time out exceptions?

1. Process Builder: If you have a process builder on the Billing object, disable some of the process builder flows or move its logic to code which executes using an asynchronous approach. 2. Another Managed Package Involved: If code from another managed package (i.e. Rollup Helper) is taking part in a transaction such as Posting a Billing you will need to contact the authors of the that managed package. 3. Custom Code: If you have custom code (i.e. trigger) you will need to contact your developer or responsible organization to refactor your current custom solutions to ensure you do not exceed the CPU time limit.

What are two reasons to use controller extensions?

1. Re-use functionality: When a necessary functionality already exists in the standard or custom controller used in the page. Using a controller extension avoids the need to recreate that functionality. 2. Require standard features: Declarative features that depend on a standard controller such as using custom buttons or if the VF page needs to be embedded in the page layout.

Testing code as different users

1. Record sharing: Record sharing of the user specified in the System.runAs method is enforced. 2. User and field-level permission: User permissions and field-level permissions in the System.runAs method are not enforced. 3. Run As Method Availability: The System.runAs method can only be used in test methods. 4. User License: User license limits are ignored, so any number of users can be created programmatically 5. DML Limit: A call to runAs counts against the total number of DML statements. 6. Nested Methods: The runAs methods can be nested, or another runAs method can be contained in a runAs method. 7. Mixed DML: Mixed DML operations can be performed by enclosing them within the runAsblock. 8. Setup Objects: Setup objects can be inserted or updated together with other sObjects using the runAs block

How do you relay events for Lightning Web Component

1. Relaying events: To relay the event down the containment hierarchy, properties can be passed from parent to child components via HTML attributes, or public methods of the nested component can be called 2. Publish-Subscribe: To propagate the event between containment hierarchies, Lightning Web Components use the same Application Event publish-subscribe model, typically with the use of a "pubsub" module.

Class Methods

1. Return Value: The data type of the returned value must be explicitly specified for a method which returns a value. If a method does not return a value, the keyword void should be used in the method definition. 2. Arguments: Method parameters, which are enclosed in parentheses, should be separated by commas where each parameter is preceded by its data type. If a method does not accept any parameters, an empty set of parentheses() can be used 3. Method Body: The body of the method containing code, including local variable declarations, is enclosed in curly brackets{}.

What are the most common security vulnerabilities?

1. SOQL Injection 2. Cross-Site Scripting (XSS) 3. Cross-Site Request Forgery (CSRF) 4. Data Access Control Issues 5. Third-Party Content Issues

XSS Attacks

1. Salesforce has implemented filters that screen out harmful characters in most output methods as one of the anti-XSS defenses 2. All standard VF components, which start with <apex>, have anti-XSS filters in place. 3. For custom JavaScript, the Force.com platform is not able to offer protection from XSS.

What is the difference between queueable and batch apex?

1. The difference between queueable and Batch Apex (which all belong to asynchronous Apex), is that you would use Batch Apex whenever you are processing a larger number of records compared to queueable. 2. Batch Apex jobs are limited to five tasks running simultaneously, whereas queueable jobs can run up to 100 3. Queueable jobs can also be connected and call one another without any limits. 4. And, with the recent updates, they have transaction finalizers similar to the Batch Apex's finish method.

Apex Scenario An auto-parts manufacturer needs a feature in their org that updates other records that meet criteria when a primary record has been updated. A developer proceeds with creating an Apex trigger on the primary object that performs a SOQL query to fetch the other necessary records to update. After deploying the trigger in the production org, users receive the "Too many SOQL queries" error when trying to update records

1. Salesforce limits synchronous SOQL queries to 100 only per Apex transaction. 2. When this limit is exceeded, a SOQL query limit exception will occur. 3. This would mean that the trigger event executed a SOQL query more than 100 times in the production org as there were more records to process that weren't in a previous org. 4. A common mistake is placing a SOQL query inside a for-loop. 5. SOQL queries should be run outside any loop statement and reduce the chances of getting this error.

Which three data types can be returned from an SOQL statements in Salesforce?

1. Single sObject 2. List of sObjects 3. Integer

Apex Savepoints

1. Sometimes during the processing of records, your business rules require that partial work (already executed DML statements) be "rolled back" so that the processing can continue in another direction. 2. Apex gives you the ability to generate a savepoint, that is, a point in the request that specifies the state of the database at that time. 3. 3. Any DML statement that occurs after the savepoint can be discarded, and the database can be restored to the same condition it was in at the time you generated the savepoint.

Stateful vs Stateless servers: VF (stateful servers); LCs (stateless servers)

1. Stateful expects a response and if no answer is received, the request is resent. 2. In stateless, the client sends a request to a server, which the server responds to based on the state of the request.

Which Salesforce resources can be accessed by Lightning Components?

1. Static Resource 2. Content Asset Files 3. SVG Resources 4. Labels 5. Internationalization Properties

Apex: static keyword

1. Static variables and methods do not require an instance of a class in order to run or be used 2. Exist independently of all other non-static (instance) variables and methods 3. Cannot access instance variables or methods, and exist only with the scope of the transaction (thread) 4. A static variable or method exist only with the context of the transaction - it means that if two records are inserted in separate actions, each one would have its own static version of the variable or method, which prevents unwanted sharing of data or errors Key point - in exam

In which three modes can a flow run?

1. System Context w/ Sharing 2. System Context w/o Sharing 3. As user

Flow Running Modes - 2

1. System Context w/ Sharing: In system context with sharing, object-level and field-level security is ignored, but record-level access is enforced. 2. System Context w/o Sharing: In system context without sharing, object-level and field-level security is ignored including record-level access

Controller Extensions - Visibility

1. System Mode: In general, controller extensions run in system mode and thereby ignore user permissions and field-level security of the current user. To respect the user's organization-wide defaults, role hierarchy, and sharing rules, the with sharing keyword can be used in the class definition 2. User Mode: However, when used to extend a standard controller, controller extensions run in user mode and thereby respects user permissions, field-level security, and sharing rules of the current user.

Trigger Context Variables - Addl Info

1. TRIGGER.OLD: Trigger.old returns a list of the old versions of the sObject records. This sObject list is only available in update and delete triggers 2. TRIGGER.NEW: Trigger.new contains a list of the new versions of sObject records that is available in insert, update, and undelete triggers. 3. TRIGGER.OPERATIONTYPE: Trigger.operationType gets context about the current DML operation. It returns an enum of type System.TriggerOperation that corresponds to the current operation 4. TRIGGER.OLDMAP: Trigger.oldMap contains a map of the previousversions of the sObject records 5. TRIGGER.NEWMAP: Trigger.newMap contains a map of the updatedversions of the sObject records 6. TRIGGER.SIZE: Trigger.size is used to determine the number of records processed in a trigger. Note that triggers execute on batches of 200 records at a time

What is queueable Apex?

1. Take control of your asynchronous Apex processes by using the Queueable interface. 2. This interface enables you to add jobs to the queue and monitor them. 3. Using the interface is an enhanced way of running your asynchronous Apex code compared to using future methods.

What are some characteristics of test methods?

1. Test methods are static, top-level methods that take no arguments. 2. They're defined with the testmethod keyword or the @isTest annotation. 3. Access modifier: public or private

Subscribing to Platform Events in External Apps

1. The Bayeux protocol (websocket & HTTP) is required in order to subscribe to platform events in an external app 2. CometD is a library that implements this protocol and can be used to subscribe to platform events in an external client 3. CometD is an event and message routing bus. A custom CometD client can be implemented or EMP Connecto rcan be utilized 4. Platform events are sent by Salesforce to CometD clients sequentially in the order they are received

Apex Primitive Data Types - 6

1. The Blob is a collection of binary data which is stored as object. 2. This will be used when we want to store the attachment in salesforce into a variable. 3. This data type converts the attachments into a single object. 4. If the blob is to be converted into a string, then we can make use of the toString and the valueOf methods for the same

Component Phases - Capture

1. The event is captured and trickles down from the application root to the source component. 2. The event can be handled by a component in the containment hierarchy that receives the captured event. 3. Event handlers are invoked in order from the application root down to the source component that fired the event. 4. Any registered handler in this phase can stop the event from propagating, at which point no more handlers are called in this phase or the bubble phase.

Key points about inner classes

1. There is no limit to the number of inner classes that can be created 2. However, an inner class can only be one-level deep. Meaning, nesting another class in an inner class is not allowed and the code cannot be compiled.

Apex Scenario A developer has created an Apex class that will be scheduled to run periodically as a maintenance and housekeeping process for a company's Salesforce org. The process involves updating and deleting records that meet certain criteria. It also requires executing the Database.emptyRecycleBin() method to help free up storage in the org. The developer is concerned if the DML statements that will be issued by the method is proportional to the number of records that will be deleted from the recycle bin.

1. The Database.emptyRecycleBin() method, regardless of how many records are processed in a single call, increments the DML counter by 1 only regarding the number of DML statements issued. 2. However, there is a limit on the number of records (DML rows) that can be processed in the call which is 10,000. 3. Meaning, if more than 10,000 records are going to be deleted when calling the method, then a limit exception will be thrown. 4. Other methods that increment the DML counter by 1 are: Approval.process(),Database.convertLead(),Database.rollback(), Database.setSavePoint(), EventBus.publish(), and System.runAs()

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

1. The LeadConvert 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. 2. A process can be created to invoke the Apex method for the lead conversion when the record is updated and meets the required criteria.

What Is the Lightning Component Framework?

1. The Lightning Component framework is a UI framework for developing single page applications for mobile and desktop devices. 2. As of Spring '19 (API version 45.0), you can build Lightning components using two programming models: the Lightning Web Components model, and the original Aura Components model. Lightning web components are custom HTML elements built using HTML and modern JavaScript. Lightning web components and Aura components can coexist and interoperate on a page.

Lightning web components that are not in the same DOM tree can communicate with each other using what?

1. The Lightning Message Service 2. The pubsub module

What are two ways to schedule Apex?

1. The Schedule Apex page in Setup 2. The System.schedule method

VF Scenario A developer of Cosmic Solutions needs to build a VF page that allows users to enter the name of an existing account, search for the account, and change the type of the account if it exists

1. The VF page can be built and associated with a custom controller that contains methods for performing a search and getting the account record entered by the user, setting the type of the account, and saving the account record. 2. For example, the custom controller can contain the following method to get the name and type of an account record specified by a user

VF Scenario The sales representatives of Cosmic Lights use a VF page in Salesforce to search for and view billing information related to any account record in Salesforce. A custom object named 'Billing__c' is used to store the billing information. The page currently uses a standard controller to retrieve the required information. The sales director of the company would like to allow the sales representatives to click a button on the page to retrieve billing information from an external system and update the corresponding record in Salesforce.

1. The VF page can use a custom controller that contains all the logic required by the page, including the execution of a callout to the external system. 2. Another way of meeting the requirement is to create a controller extension that contains the callout logic. It can extend the functionality of the standard controller used by the page.

Difference between virtual and abstract

1. The basic difference between a virtual and abstract class is that methods in virtual class CAN be overridden in derived classes, while abstract class methods MUST be overridden.

What's happening with this class? public class Leads { // First a no-argument constructor public Leads () {} // A constructor with one argument public Leads (Boolean call) {} // A constructor with two arguments public Leads (String email, Boolean call) {} // Though this constructor has the same arguments as the // one above, they are in a different order, so this is legal public Leads (Boolean call, String email) {} }

1. The class has 4 constructors 2. The last two have the same arguments, but in different order, which is allowed

What is happening with this class? public class TestObject2 { //Variable declaration private static final Integer DEFAULT_SIZE = 10; Integer size; //Constructor with no arguments public TestObject2(){ this(DEFAULT_SIZE);//Using this...calls the one argument constructor } //Constructor with one argument public TestObject2(Integer Objectsize){ size = Objectsize; } }

1. The class has two constructors: one with no arguments and one wit arguments 2. The first constructor calls the second one using the this keyword

Component Phases - Bubble

1. The component that fired the event can handle it. The event then bubbles up from the source component to the application root. 2. The event can be handled by a component in the containment hierarchy that receives the bubbled event. 3. Event handlers are invoked in order from the source component that fired the event up to the application root. 4. Any registered handler in this phase can stop the event from propagating, at which point no more handlers are called in this phase.

Application Event Propagation - Bubble

1. The component that fired the event can handle it. The event then bubbles up from the source component to the application root. The event can be handled by a component in the containment hierarchy that receives the bubbled event. 2. Event handlers are invoked in order from the source component that fired the event up to the application root. 3. Any registered handler in this phase can stop the event from propagating, at which point no more handlers will be called in this phase. If a component stops the event propagation using event.stopPropagation(), the component becomes the root node used in the default phase. 4. Any registered handler in this phase can cancel the default behavior of the event by calling event.preventDefault(). This call prevents execution of any of the handlers in the default phase.

What are some limitations of roll-up summary fields?

1. There is a max number of roll-up summary fields per object 2. Does not work for lookups 3. Cannot rollup a formula field that references a field on another object or contains dynamic date function.

Application Event Propagation - Capture

1. The event is captured and trickles down from the application root to the source component. The event can be handled by a component in the containment hierarchy that receives the captured event. Event handlers are invoked in order from the application root down to the source component that fired the event. Any registered handler in this phase can stop the event from propagating, at which point no more handlers are called in this phase or the bubble phase. If a component stops the event propagation using event.stopPropagation(), the component becomes the root node used in the default phase.

Batch Apex

1. The execution logic of the batch class is called once for each batch of records. The default batch size is 200 records. 2. You can also specify a custom batch size. 3. Each batch execution is considered a discrete transaction. 4. With each new batch of records, a new set of governor limits is in effect. In this way, it's easier to ensure that your code stays within the governor execution limits. 5. Another benefit of discrete batch transactions is to allow for partial processing of a batch of records in case one batch fails to process successfully, all other batch transactions aren't affected and aren't rolled back if they were processed successfully.

Queueable Apex - Things to Rember

1. The execution of a queued job counts once against the shared limit for asynchronous Apex method executions. 2. You can add up to 50 jobs to the queue with System.enqueueJob in a single transaction. 3. When chaining jobs, you can add only one job from an executing job with System.enqueueJob, which means that only one child job can exist for each parent queueable job. Starting multiple child jobs from the same queueable job is a no-no. 4. No limit is enforced on the depth of chained jobs, which means that you can chain one job to another job and repeat this process with each new child job to link it to a new child job. However, for Developer Edition and Trial orgs, the maximum stack depth for chained jobs is 5, which means that you can chain jobs four times and the maximum number of jobs in the chain is 5, including the initial parent queueable job.

Component Event Propagation

1. The framework supports capture and bubble phases for the propagation of component events. 2. These phases are similar to DOM handling patterns and provide an opportunity for interested components to interact with an event and potentially control the behavior for subsequent handlers. 3. The component that fires an event is known as the source component. 4. The framework allows you to handle the event in different phases. These phases give you flexibility for how to best process the event for your application.

Application Event Propagation

1. The framework supports capture, bubble, and default phases for the propagation of application events. 2. The capture and bubble phases are similar to DOM handling patterns and provide an opportunity for interested components to interact with an event and potentially control the behavior for subsequent handlers. 3. The default phase preserves the framework's original handling behavior.

VF pages and Process order

1. The order of methods and variables being processed is not guaranteed 2. If the value of a variable that is set by another method is needed, the method can be called directly to ensure that the variable of interest has been set.

Lookup deletion options

1. The parent can be prevented from being deleted if children exist 2. Children can also be deleted when parent is deleted (requires Salesforce support).

Safe Navigation Operator

1. The safe navigation operator (?.) can be used to avoid null pointer exceptions. 2. When an expression attempts to operate on a null value, null is returned instead of the NullPointerException thrown. The operator can be used in the following syntax: a = b?.c where null will be returned to a if b evaluates to null. Otherwise, b.c will be returned. Using the ternary operator, it can also be interpreted as: a = (b == null) ? null : b.c

Scratch org

1. The scratch org is a source-driven and disposable deployment of Salesforce code and metadata. 2. A scratch org is fully configurable, allowing developers to emulate different Salesforce editions with different features and preferences. 3. You can share the scratch org configuration file with other team members, so you all have the same basic org in which to do your development. 4. In addition to code and metadata, developers can install packages and deploy synthetic or dummy data for testing. Scratch orgs should never contain personal data. 5. Scratch orgs drive developer productivity and collaboration during the development process, and facilitate automated testing and continuous integration.

Transient variables

1. The transient keyword is used to declare variables that cannot be saved. 2. One common usage is a field on a Visualforce page that is utilized only during the page request. 3. Transient variables will not be transmitted as part of the view state.

Upsert and Merge DML Statements

1. The upsert DML operation creates new records and updates sObject records within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified. 2. The merge statement merges up to three records of the same sObject type into one of the records, deleting the others, and re-parenting any related records.

Using Upsert DML

1. The upsert statement matches the sObjects with existing records by comparing values of one field. 2. If you don't specify a field when calling this statement, the upsert statement uses the sObject's ID to match the sObject with existing records in Salesforce. 3. Alternatively, you can specify a field to use for matching. For custom objects, specify a custom field marked as external ID. For standard objects, you can specify any field that has the idLookup property set to true

Best Practices for Apex Classes & Triggers - USE QUERIES AND FOR LOOPS EFFICIENTLY

1. The use of multiple SOQL queries to retrieve the records of a single object should be avoided if a single query with multiple filters can be utilized. 2. Relationships can be utilized to reduce the number of queries required to retrieve the records. 3. Also, the use of multiple for loops to loop through records should be avoided, if a single for loop with if statements can be used instead.

An org has been having issues with governor limits related to heap size as a result of a query that returns too many records. A developer wants to write what is called a SOQL for loop to help mitigate the issue and at the same time process records in batches. If the name of the variable to use is var and the SOQL statement to execute is "SELECT Id, Name FROM Account", how should the SOQL for loop be declared? Important slide about SOQL for loops

1. This syntax does batches of 200 for (List<Account> var: [SELECT Id,Name FROM Account]){ System.debug(var); } 2. This syntax does 1 record at at a time for (Account var: [SELECT Id,Name FROM Account]){ System.debug(var); }

Interface Scenario 2 (purging old data from Salesforce) A Salesforce org over the years has accumulated a number of old records that can already be deleted. The head of operations is asking the Salesforce developer to design and set up a maintenance routine for the org which needs to be run automatically on a periodical basis from this point onwards.

1. To achieve this requirement, an Apex class in the form of a scheduled job can be run to delete records that meet criteria and handle other necessary procedures involved in the maintenance process 2. To schedule an Apex to run at predefined intervals, it can implement the Schedulable interface. 3. After which, it can then be scheduled in the Scheduled Jobs page in Setup, or programmatically using the System.schedule method

Best Practices and Considerations - Run within the heap size limit

1. To avoid exceeding the heap size, SOQL for-loops should be used to process records in batches especially when handling large data sets. 2. Using transient variables for Visualforce pages, removing items in a collection after use, and using the Limits.getHeapSize() and Limits.getLimitHeapSize() methods are helpful

Interface Scenario 3 (Batch jobs) A multi-national company manages an org with millions of records and hundreds of users who access the platform on a daily basis. The Salesforce administrator needs to run a process for opportunity records in the org. It will assess and identify what needs to be done to the record such as to archive or keep the record, reassign to another user, or update certain fields such as type, close dates, etc.

1. To avoid hitting governor limits, Batch Apex can be used to run the process. 2. It is capable of processing thousands or even millions of records. Every transaction in batch Apex starts with a new set of governor limits. 3. Also, when a batch transaction fails, all the other successful batch transactions will not be rolled back. 4. Batch Apex is an Apex class that implements the Database.Batchable interface

How can you prevent a recursive trigger?

1. To avoid recursive triggers you can create a class with a static Boolean variable with default value true. 2. In the trigger, before executing your code keep a check that the variable is true or not. 3. Once you check make the variable false.

How to create custom exceptions

1. To create your custom exception class, extend the built-in Exception class and make sure your class name ends with the word Exception, such as "MyException" or "PurchaseException". 2. All exception classes extend the system-defined base class Exception, and therefore, inherits all common Exception methods.

SOQL Injection Defenses

1. To prevent a SOQL injection attack, avoid using dynamic SOQL queries. Instead, use static queries and binding variables. 2. If you must use dynamic SOQL, use the escapeSingleQuotes method to sanitize user-supplied input.

Subscribing a Lightning Web Component to a Platform Event

1. To subscribe to a platform event using a Lightning web component, the empApi methods are imported from the lightning/empApi module 2. The name of the platform event channel is required for subscribing to the platform event. The name is case-sensitive and follows this format: '/event/Event_Name__e'

What needs to b added to a Lightning Component so that it can be supported in quick actions?

1. To support quick actions, the lightning__RecordActiontarget is added. 2. o launch the component in a window, the actionType property is set to ScreenAction. To execute a headless action, the property is set to Action 3. To launch a headless quick action, a method called invoke() is exposed using the @api decorator.

Scheduled Apex

1. To take advantage of the scheduler, write an Apex class that implements the Schedulable interface, and then schedule it for execution on a specific schedule. 2. To invoke Apex classes to run at specific times, first implement the Schedulable interface for the class. Then, schedule an instance of the class to run at a specific time using the System.schedule() method. 3. The class implements the Schedulable interface and must implement the only method that this interface contains, which is the execute() method. 4. The parameter of this method is a SchedulableContext object. After a class has been scheduled, a CronTrigger object is created that represents the scheduled job. It provides a getTriggerId() method that returns the ID of a CronTrigger API object.

How do you test future methods?

1. To test future methods, enclose your test code between the startTest() and stopTest() test methods. 2. The system collects all asynchronous calls made after the startTest(). 3. When stopTest() is executed, all these collected asynchronous processes are then run synchronously. 4. You can then assert that the asynchronous call operated properly.

Flow - Limits Per Transaction - 1

1. Total number of SOQL queries issued: 100; You can only use a maximum of 100 data elements that retrieve the data 2. Total number of DML statements issued: 150; You can only use a maximum of 150 data elements that modify the data. (Note that these elements will also be multiplied if they are within the loop, which is why you often hear the best practice is "No Pink in Loop".) 3. Total number of records retrieved by SOQL queries: 50,000; You can only retrieve a maximum of 50,000 records.

What settings do you need to provide when setting up a trace flag?

1. Traced Entity Type 2. Traced Entity Name 3. Start Date (Date Time) 4. Expiration Date (Date Time) 5. Debug Level (needs to be pre-defined)

Points about using a platform event and trigger to publish information to external system

1. Trigger (or flow) can publish a platform event 2. Trigger can use the EventBus.pubish() method to publish the event 3. Externa system can subscribe to Salesforce using CometD and perform long polling for obtaining information

Additional key points about triggers

1. Trigger is stored as metadata under respective object 2. A developer can specify the version of Apex and API to be used with the trigger 3. Triggers cannot be used to detect undelete events 4. For attachment, ContentDocument, and Note standard objects, a trigger can be created via the UI or developer console

Variable Scope

1. Two variables with the same name cannot exist in the same scope, or in the same "hierarchy" of blocks they are contained in 2. Blocks that are parallel to each other can declare the same variable names since their variables will not exist in each other's scope 3. An error is thrown here since another variable with the same name is being declared in the same scope

Work with the Generic sObject Data Type

1. Typically, you use the specific sObject data type, such as Account for a standard object or Book__c for a custom object called Book, when working with sObjects 2. However, when you don't know the type of sObject your method is handling, you can use the generic sObject data type. 3. Variables that are declared with the generic sObject data type can reference any Salesforce record, whether it is a standard or custom object record.

Types of Lightning Components

1. UI Component: This type of Lightning Web Component is a custom component that users can interact with via a user interface such as clicking on a button, filling out a field on a form, etc. This type of component will require an HTML file, JavaScript file, and metadata configuration file 2. Service Component (Library): This type of Lightning Web Component serves a helper library and is called a service component. It is created to have variables or functions that can be shared between components. This type of component only requires a JavaScript file and metadata configuration file.

Difference between DML statements and database methods

1. Unlike DML statements, Database methods have an optional allOrNone parameter that allows you to specify whether the operation should partially succeed 2. When this parameter is set to false, if errors occur on a partial set of records, the successful records will be committed and errors will be returned for the failed records. Also, no exceptions are thrown with the partial success option.

Additional characteristics of future methods

1. Use @future annotation before the method declaration. 2. Future methods must be static methods and can only return a void type. 3. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. 4. Future methods can't take standard or custom objects as arguments. 5. A common pattern is to pass the method a list of record IDs that you want to process asynchronously. 6. Future methods cannot call other future methods

Bulk Triggers

1. Use Collections: Sets and maps can be used to reduce the number of data operations and act on multiple records at onetime. 2. Bulk Operations: Bulk triggers can handle bulk operations like data import, bulk API calls, mass actions, and recursive Apex methods and triggers 3. Avoid Limit Exceptions: If a trigger is not designed to process thousands of records at once, it may reach the DML statement limit per transaction 4. Using DML Statements: A trigger designed to handle records in bulk should only use one DML statement.

Lightning Data Service

1. Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. 2. Lightning Data Service handles sharing rules and field-level security for you. 3. In addition to simplifying access to Salesforce data, Lightning Data Service improves performance and user interface consistency. 4. At the simplest level, you can think of Lightning Data Service as the Lightning components version of the VF standard controller. 5. While this statement is an over-simplification, it serves to illustrate a point. Whenever possible, use Lightning Data Service to read and modify Salesforce data in your components

A developer needs to display all of the available fields for an object. In which two ways can the developer retrieve the available fields if the variable myObject represents the name of the object?

1. Use Schema.describeSObjects(new String[]{myObject})[0].fields.getMap() to return a map of fields. 2. Use mySObject.myObject.fields.getMap() to return a map of fields.

Business Accounts/Person Accounts - VF - Additional Considerations

1. Use a custom name formula field to ensure both person and business accounts render properly on a page and use this field instead of the standard fields 2. The type of account created (business or person) depends on which name field is used in the insert statement 3. When referencing the Name field using <apex: inputField>, you must reference isPersonAccount in the query.

How can a parent component pass a string value to a child component?

1. Use a public property 2. Use a custom event

TestVisible Annotation

1. Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. 2. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. 3. This annotation doesn't change the visibility of members if accessed by non-test classes.

WITH SECURITY_ENFORCED What about record security?

1. Use the WITH SECURITY_ENFORCED clause to enable field- and object-level security permissions checking for SOQL SELECT queries in Apex code, including subqueries and cross-object relationships. 2. WITH SECURITY_ENFORCED applies field- and object-level security checks only to fields and objects referenced in SELECT or FROM SOQL clauses and not clauses like WHERE or ORDER BY.

A developer is implementing an Apex class for a financial system. Within the class, the variables 'creditAmount' and 'debtAmount' should not be able to change once a value is assigned. In which two ways can the developer declare the variables to ensure their value can only be assigned one time?

1. Use the final keyword and assign its value in the class constructor 2. Use the final keyword and assign its value when declaring the variable.

stripInaccessible Can be for queries and DML statements for field and object-level security

1. Use the stripInaccessible method to enforce field- and object-level data protection. This method can be used to strip the fields and relationship fields from query and subquery results that the user can't access. 2. The method can also be used to remove inaccessible sObject fields before DML operations to avoid

Actions

1. User interaction with an element on a component or app. User actions trigger events, but events aren't always explicitly triggered by user actions. 2. This type of action is not the same as a client-side JavaScript controller, which is sometimes known as a controller action. 3. The following button is wired up to a browser onclick event in response to a button click. <lightning:button label = "Click Me" onclick = "{!c.handleClick}" />

Invoking Apex from a Process

1. Values: if the class includes an invocable variable, values for sObject or primitive type list variables can be entered manually or field values from a related record can be used 2. Attributes: Annotation attributes 'label' and 'description' are supported by invocable methods and variables 3. Required Variable: Invocable variables also support the 'required' modifier which specifies whether the variable is required and adds a prompt in the UI Need to study

What resources are available in flow for before-save record triggered flow?

1. Variable: 2. Constant 3. Formula 4. Text Template 5. Stage

Definition Modifiers

1. Virtual: The virtual definition modifier is used to declare that a class allows extension and overrides 2. Abstract: The abstract definition modifier is used to declare that a class contains abstracts methods which only have signature and nobody definition.

Additional Sharing Modes

1. WITH SHARING: Ensures that the Apex class will enforce the sharing rules of the current user. 2. WITHOUT SHARING: Ensures that the Apex class does not respect sharing rules and runs in system context. 3. INHERITED SHARING: Inherits the sharing settings of the calling class or depends on how the Apex class is used.

Pagination using standard set controller salesforce

1. We can use Standard set controllers provided by salesforce to implement pagination in VF 2. It is very easy to implement pagination using standard set controller. 3. We can easily navigate through pages, move directly to first, last page or to next or previous pages using standard set controller. We can also decide how many records should be displayed in every page. 4. We need to instantiate the StandardSetController and use the standard methods provided by salesforce to leverage the pagination functionality.

Queueable Apex

1. We took the simplicity of future methods and the power of Batch Apex and mixed them together to form Queueable Apex 2. It is called by a simple System.enqueueJob() method, which returns a job ID that you can monitor.

Salesforce polymorphic fields

1. WhatId is a single relationship to an ACCOUNT or OPPORTUNITY. This activity can only be associated with ONE Account OR Opportunity Record. 2. WhoId is a one to many relationship between this activity to one or more CONTACTS or LEADS.

What happens when a new Apex job is invoked?

1. When a batch Apex job is invoked, a new record is added in the AsyncApexJob table that has information about the batch job, such as its status, the number of batches processed, and the total number of batches to be processed. 2. The finish method sends an email to the job's submitter to confirm the job completion. 3. It performs a query on the AsyncApexJob object to get the status of the job, the submitter's email address, and other information. 4. It then creates a new email message and sends it using the Messaging.SingleEmailMessage methods.

What Happens When an Exception Occurs?

1. When an exception occurs, code execution halts and any DML operations that were processed prior to the exception are rolled back and aren't committed to the database. 2. Exceptions get logged in debug logs. 3. For unhandled exceptions, that is, exceptions that the code doesn't catch, Salesforce sends an email to the developer with the organization ID and user ID of the running user, as well as the exception message.

Flows and Quick Actions

1. When launching a flow from a quick action, the record is automatically passed to the flow 2. When a flow is invoked from a Lightning page, a checkbox in Lightning App Builder can be used to let the page pass the record to the flow automatically

Cast Generic sObjects to Specific sObject Types

1. When you're dealing with generic sObjects, you sometimes need to cast your sObject variable to a specific sObject type. 2. One of the benefits of doing so is to be able to access fields using dot notation, which is not available on the generic sObject. 3. Since sObject is a parent type for all specific sObject types, you can cast a generic sObject to a specific sObject.

Where can you make a lookup field required?

1. Within lookup field definition 2. On page layout

Sandbox Cloning

1. You can create a sandbox by cloning an existing sandbox rather than using your production org as your source. 2. Save time by customizing a sandbox with a set of data and metadata and then replicating it. Sandbox cloning simplifies having multiple concurrent streams of work in your application life cycle. 3. You can set up a sandbox for each type of work, such as development, testing, and staging. 4. Your colleagues can easily clone individual sandboxes instead of sharing one sandbox and avoid stepping on each other's toes.

For the purposes of testing Apex, how can test data be created?

1. You can create test data either in your test method 2. You can write utility test classes containing methods for test data creation that can be called by other tests.

Schedulable Apex - Things to Remember

1. You can only have 100 scheduled Apex jobs at one time and there are maximum number of scheduled Apex executions per a 24-hour period. See Execution Governors and Limits in the Resources section for details. 2. Use extreme care if you're planning to schedule a class from a trigger. You must be able to guarantee that the trigger won't add more scheduled jobs than the limit. 3. Synchronous Web service callouts are not supported from scheduled Apex. To be able to make callouts, make an asynchronous callout by placing the callout in a method annotated with @future(callout=true) and call this method from scheduled Apex. However, if your scheduled Apex executes a batch job, callouts are supported from the batch class.

Bulk DML

1. You can perform DML operations either on a single sObject, or in bulk on a list of sObjects. 2. Performing bulk DML operations is the recommended way because it helps avoid hitting governor limits, such as the DML limit of 150 statements per Apex transaction. 3. This limit is in place to ensure fair access to shared resources in the Lightning Platform. 4. Performing a DML operation on a list of sObjects counts as one DML statement, not as one statement for each sObject.

Apex Email Service

1. You can use email services to process the contents, headers, and attachments of inbound email. For example, you can create an email service that automatically creates contact records based on contact information in messages. 2. You can associate each email service with one or more Salesforce-generated email addresses to which users can send messages for processing. To give multiple users access to a single email service, you can: a. Associate multiple Salesforce-generated email addresses with the email service and allocate those addresses to users. b. Associate a single Salesforce-generated email address with the email service, and write an Apex class that executes according to the user accessing the email service. For example, you can write an Apex class that identifies the user based on the user's email address and creates records on behalf of that user.

Custom Exceptions

1. You can't throw built-in Apex exceptions. You can only catch them. 2. Custom exceptions enable you to specify detailed error messages and have more custom error handling in your catch blocks. 3. Exceptions can be top-level classes, that is, they can have member variables, methods and constructors, they can implement interfaces, and so on.

A few things to know about Before Delete flows:

1. You cannot use a before delete flow to prevent a record from being deleted like you can with a Before Delete trigger. 2. You cannot call subflows out of the box. 3. However, until Salesforce provides that ability in Flow Builder, you can install an apex action Call Subflow created by Narender Singh. 4. You cannot use the debug feature with record-triggered flows. Like processes, you need to activate the flow and test it in the sandbox. Need to use trigger to prevent deletion of record

Apex Code Coverage

1. You must have at least 75% of your Apex covered by unit tests to deploy your code to production environments. 2. All triggers must have at least one line of test coverage (why are they claiming 1%? 3. We recommend that you have 100% of your code covered by unit tests, where possible. 4. Calls to System.debug are not counted as part of Apex code coverage in unit tests.

Classes and casting

1. a data type of one class can be assigned to a data type of another class, but only if one class is a subclass of the other class. 2. Use casting when you want to convert an object from one data type to another. 3. In the following example, CustomReport extends the class Report. Therefore, it is a subclass of that class. 4. This means that you can use casting to assign objects with the parent data type (Report) to the objects of the subclass data type (CustomReport).

Which error methods does the sObject class have that can be used for testing?

1. addError(): dynamically add error to fields of an sObject associated with the specified field 2. hasErrors(): returns true if an object instance contains any errors 3. getErrors(): used to retrieve a list of errors (list) that are added to an object instance

What options are available to access the token for an object in Apex?

1. getSObjectType method 2. sObjectType static member variable

Tokens: getSObjectType & getSObjectField

1. getSObjectType: Object token - the getSObjectTypemethod can be used to access the token for an object. 2. getSObjectField - Field token - the getSObjectFieldmethod can be used to access the token for a field

DescribeFieldResult Class

1. isAccessible(): Returns true if the current user can see this field, false otherwise. 2. isCreateable(): Returns true if the field can be created by the current user, false otherwise. 3. isUpdateable(): Returns true if the field can be edited by the current user, or child records in a master-detail relationship field on a custom object can be reparented to different parent records; false otherwise.

DescribeSObjectResult Class

1. isAccessible(): Returns true if the current user can see this object, false otherwise. 2. isCreateable(): Returns true if the object can be created by the current user, false otherwise. 3. isDeletable(): Returns true if the object can be deleted by the current user, false otherwise. 4. isMergeable(): Returns true if the object can be merged with other objects of its type by the current user, false otherwise. true is returned for leads, contacts, and accounts. 5. isUndeletable(): Returns true if the object can be undeleted by the current user, false otherwise. 6. isUpdateable(): Returns true if the object can be updated by the current user, false otherwise.

Apex Scenario A digital marketing company needs to update the status of all ongoing opportunities when a product associated with its opportunity line items needs to be phased out. A button was created to run the Apex method that performs the update. However, there were instances that the process would encounter the "Too many DML statements" when users were testing the process.

1. n a single Apex transaction, DML statements can only be executed up to 150 times only. 2. If this limit is exceeded, a limit exception is encountered. 3. This is bound to happen when DML statements are run in a loop because it was programmed to operate on a single record at a time only. 4. To avoid this error, records must be processed in batches by executing an update operation, for example, on a list of records outside the loop. 5. The job of the loop is to collect the records in a list. This greatly reduces the need to run the DML statement more than necessary.

Orchestrator and Orchestration Building Blocks - 2

3. Flows: Each orchestration step runs an associated flow. Background steps call auto-launched flow while interactive steps assign a screen flow to a user, group, or queue. A flow can be opened from the orchestration page 4. Orchestration Work Items: When an interactive step runs, a work item is created and assigned to a user, group, or queue. Work items can be viewed in the Orchestrator Work Guide Lightning record page component. An email with a link to the specified record page is sent to all assignees

Using Access Modifiers - 2

4. Global: The global access modifier means that the method or variable can be used by any Apex code that has access to the class and not just the Apex code in the same application 5. Protected: The protected access modifier means that the method or variable is visible to any inner classes in the defining Apex class, and to the classes that extend the defining Apex class.

What can a Lightning component contain?

A Lightning web component follows web standards and typically contain an: - HTML - JavaScript - CSS - configuration (XML) file

Access to Resources - 1

A Lightning web component has access to Static Resources, SVG Resources, Content Asset Files, Labels, Internationalization Properties, Current User Information, and Client Form Factor.

How many records can be processed by a SOQL for loop at time?

A SOQL for loop can process records one at a time using an sObject variable, or in batches of 200 sObjects at a time using an sObject list.

Which best practice should be used to avoid exceeding the heap limit?

A SOQL for loop should be used to process multiple batches of the resulting records through the use of internal calls to query and queryMore

Best Practices and Considerations - Count Function

A SOQL query that uses the COUNT() or COUNT(fieldname) function to return an integer only counts as one query row towards the governor limit.

Flow & Slack Notifications

A Slack notification can be sent from Salesforce using the Send Notification core action in Flow Builder. For more complex requirements, the invocable action API can be used instead.

Scenario A company who has just migrated to the Lightning Experience interface wants to see how it can reuse some of its VF pages by displaying them on a user interface along with the other components that they have added on a Lightning page using Lightning App Builder. They are also exploring on the possibility of embedding multiple screen flows on a single Lightning page that served as utility tools which they frequently use in their internal business processes.

A VF page can be embedded on a Lightning Record page using the VF standard Lightning component when the Available for Salesforce mobile apps and Lightning pages settings of the page is enabled. Another method of loading a VF page is by adding the page in the page layout of the object. The page layout is displayed through the standard Record Detail component. However, the VF page must only implement the standard controller of the object that is associated with the page layout in order for it to appear as an option in the page layout editor. Screen flows can be embedded as well on a Lightning page by using the Flowstandard Lightning component in Lightning App Builder. User interface layout options such as number of columns are available in its settings. These flows can also execute invocable Apex methods.

Visualforce Pages with Lightning Experience Stylesheets

A VF page can be styled with the look of Lightning Experience when viewed in Lightning Experience or the Salesforce mobile app 1. Page attribute: the lightningStylesheets attribute can be used in the <apex:page> tag of a VF page to style the page to match the Lightning Experience UI when viewed in Lightning Experience or the Salesforce app 2. Scoping class: The CSS scoping class, slds-vf-scope, is automatically applied to the VF page's <body> element when lightningStyleSheets is set to true. If the applyBodyTag or applyHtmlTag is set to false, the scoping class must be manually added to the <body> tag.

What can you use with a binding variable in Apex and SOQL?

A collection of Ids using a Set or List can also be used or referenced in the WHERE clause.

What if a flow collection variable?

A collection variable stores multiple values of the same data type - or records of the same object - in an ordered list. To iterate over a collection variable, use a Loop element.

Apex Design Patterns - Command Pattern

A command pattern is a data-driven design pattern and falls under the behavioral pattern category. A request is wrapped under an object as a command and passed to the invoker object. Invoker object looks for the appropriate object which can handle this command and passes the command to the corresponding object which executes the command.

Component Events

A component event can be handled by all the components in the containment hierarchy as long as they have handlers configured to handle the event. 1. Containment hierarchy: A containment hierarchy refers to a tree of components that has a top-level container as its root component. When an event is triggered, all components within the containment hierarchy are notified. 2. Component Event Propagation: How an event is propagated in the containment hierarchy depends on the phase that is configured in the event handler. There are two types of phases available for component events, namely, Bubble and Capture.

Scenario A developer has created two Aura components named contactList.cmp and contactUpdate.cmp for the Account page in Lightning Experience. The contactList.cmp component should allow users to view all the contacts associated with the account and select a contact record. When a contact record is selected, the contactUpdate.cmp component should allow users to update certain fields on the record. The contactList.cmp component is the child of the contactUpdate.cmp component.

A component event can be utilized for this requirement. The contactList.cmp component can fire a component event when a contact record is selected. The contactUpdate.cmp component can handle the event fired by its child component. The capture phase can be used for event propagation since it allows the root component to handle the event first. In this case, the parent component (contactUpdate.cmp) is the root component.

Difference between VF custom controller and controller extension

A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your VF page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user. A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when: 1. You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete. 2. You want to add new actions. 3. You want to build a VF page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.

Flow Running Modes - 1

A flow can be configured to run in the following modes which determine its level of access to data. Changing the running context are supported in screen flows and auto-launched flows. User Context or System Context: In this setting, a flow may run in user context or system context depending on how the flow is configured to launch.

Using Flow.Interview to Start a Flow

A flow can be referenced in Apex by defining the flow using the Flow.Interview.flowName syntax. The example below uses this method to create a flow interview object and then invokes it.

Additional Apex Scenarios A method returns a list of sObjects which object types are unknown beforehand as the object type is only determined during run-time. Once the type is determined, a field is updated for all the records. How can an Apex control flow be used to handle this requirement?

A for-loop statement can be used in combination with a switch statement. An if-else statement can also be used instead of a switch statement by using the instanceof keyword to identify the object type. The following can be written where records is the sObject collection variable returned from the method Good example of using a switch statement with generic sObject

A company in the real estate business needs to store the locations of their client's properties. Then, based on that information, a virtual map needs to be generated using Apex and a frontend mapping library

A geolocation field can be used to store the location of areal estate property. To access each coordinate, the field name plus the suffix is specified. If "Property Location" is the field name, for example, then the API names are: Property_Location__latitude__sProperty_Location__longitude__s

fire()

Fires an event (Aura component)

Which fields can you search with SOSL? A. Text B. Picklist C. Email D. Phone E. Checkbox

A, C, D Acronym: SOQL Search Fields: TEP (Text, Email, Phone)

What objects can be imported with Data Import Wizard?

Accounts, Contacts, Leads, Solutions, Campaign Members, Person accounts, and custom objects

Action-Aware Tags

Action methods can be called using the action attribute that is supported in the following Visualforce tags

Action Methods

Action methods can be used in a custom controller to respond to user input on a Visualforce page such as the clicking of a button or link

Using Standard Controller Actions

Action methods perform logic or navigation when a page event occurs, such as when a user clicks a button, or hovers over an area of the page.

Which fields can you search with SOSL

All field, Some fields, email field, Sidebar fields

Apex and optimized queries

All the necessary data should be retrieved in a single query, the results placed in a collection, then the results iterated over

CPU Timeout Exception

An Apex CPU Timeout Exception effectively means that Apex Code (or process builder/ flows or both) is attempting to execute and is exceeding the cpu time limit allocated by Salesforce. Salesforce imposes a limit on the CPU usage that can be consumed in a given transaction, which is approximately 10 seconds for Synchronous, 60 seconds for Asynchronous. It is important to note that any DML executions contained within the transaction will be rolled back if the limit is hit Possible contributors to CPU Timeout Exception scenarios: All Apex code Library functions exposed in Apex Workflow executions

Implementing Process.Plugin in a Screen Flow

An Apex class that implements the Process.Plugininterface can be used as an action in a flow. Note: Apex classes that implement the Process.Plugin interface can be found under Apex Action (Legacy) type

Declaring Methods

An Apex method consists of statements grouped together as a single unit in an Apex class that perform a specific business logic.

Study following scenario A record contains several URL fields, and the status code of each link needs to be stored in dedicated fields after the record is saved.

An Apex trigger can be created to perform asynchronous HTTP callouts to retrieve the status code of each link and save it to the necessary fields.

What can a Aura component contain?

An Aura component or app can contain various resources which are part of a component bundle. The markup (a .cmp or .app file) is its only required resource. Other resources can be a: - controller - helper - CSS styles - design - documentation - renderer - SVG file

Schedule-Triggered Flows

An Autolaunched flow can be configured to run on a set schedule and frequency.

SOQL For Loop

An SOQL for loop processes the results of an SOQL query that is defined in the loop: 1. sObject type: Data type of the variable should be the same sObject type of the records returned by the SOQL query. 2.Single or batch: Query results are processed in batches of 200 records or one record at a time depending on the variable data type used 3. Iterate Results: A SOQL for loop can be used to iterate over all sObject records returned by a SOQL query. 4. Single or Multiple: SOQL for loops can process records one at a time using an sObject variable, or in batches of 200 sObjects at a time using an sObject list 5. Chunking Results: All sObjects are retrieved using efficient chunking with calls to the query and queryMore methods of the SOAP API. 6. Avoid Heap Size Limit: A SOQL for loop should be used to process query results that return many records, in order to avoid the limit on heap size.

Using Access Modifiers - 1

An access modifier, such as private or public, can be used when defining an Apex method or variable 1. Required: One must use an access modifier in the declaration of a top-level Apex class 2. Default: The default access modifier is private, which means that the method or variable can only be accessed within the Apex class in which it is defined. 3. Public: The public access modifier means that the method or variable can be used by any Apex in the application or namespace.

What is a benefit of using an after insert trigger over using a before insert trigger?

An after insert trigger allows a developer to insert other objects that reference the new record.

What happens after an update trigger is fired and all records have been updated?

An after update trigger is fired once all records have been updated. At this state, records in Trigger.new are in read-only mode and cannot be altered as they are already saved.

Application Events

An application event follows a publish-subscribe model where the event is fired from a source component and all components in the application are notified.

Application Event Propagation

An application event has three types of phases, namely, Bubble, Capture, and Default. The order of the event propagation for the bubble and capture phases in an application event is the same as the component event. When using the default phase, the event handlers are invoked in a non-deterministic order. It does not follow the same propagation rules related to the component hierarchy as the capture and bubble phases. Instead, the event is broadcast to all components in the application.

Platform Event-Triggered Flows

An autolaunched flow can be configured to automatically runupon receivingevent messages from a platform event that the flow is subscribed to. 1. Record Access: Platform event-triggered flows can access all available records and do not need to be associated with an object 2. Global Variable: The $Record global variable contains the field values from the platform event message which can be used throughout the flow.

Outer and Inner Classes

An inner class can be defined inside a top-level class, which will be then referred to as the outer class. If unspecified, an inner class defaults to private and is accessible only to the outer class.

Orchestration Run Status and Milestone

An orchestration run is a running instance of an orchestration. An orchestration run has an associated status and log milestones. 1. Status: The status determines the state of an orchestration run. The status values include Not Started, In Progress, Completed, Discontinued, Canceled, and Error. 2. Milestones: The milestones indicates whether the orchestration run has started and been completed. The values include "Start Run" and "End Run".

Flow: Subscribing to platform events - 2

Another method for subscribing to a platform event in Flow Builder is through the Pause element. The Pause element can be configured to resume a paused flow when it receives a platform event message.

<apex:include>

Another way to include content from one page into another is to use the <apex:include> component. This lets you duplicate the entire contents of another page, without providing any opportunity to make any changes as you did with the templates.

Getter & Setter Memorization Tip

Apex Controller --> Getter --> VF Page Apex Controller <-- Setter <--- VF Page

Apex-based email scenario: A contact record needs to be created based on contact information in email messages received by a business.

Apex Email Service can be used for this use case, as it allows the use of custom logic to process the contents of inbound email

Locking Statements

Apex allows you to lock an sObject record to prevent other code from making changes to it. Use the FOR UPDATE SOQL statement to lock a record (came up in other cert). Example: Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];

Publishing Platform Events

Apex can be used to publish platform event messages using the EventBus.publish method. In this example, a platform event is published when an opportunity is updated to 'Closed Won'.

Data Access Control

Apex class executes in system mode and may expose sensitive data to unintended users

Defining webservice methods

Apex class methods can be exposed as custom SOAP Web service calls. This allows an external application to invoke an Apex Web service to perform an action in Salesforce. Use the webservice keyword to define these methods. global class MyWebService { webservice static Id makeContact(String contactLastName, Account a) { Contact c = new Contact(lastName = contactLastName, AccountId = a.Id); insert c; return c.id; } }

Sharing Behavior in @AuraEnabled Apex Controllers

Apex classes that contain @AuraEnabled methods, which are exposed to Lightning components, default to with sharing when no sharing behavior is explicitly defined in the class.

Invoking a Flow Statically

Apex code below invokes a flow which adds two numeric input values and then return its sum.

Apex and Flow

Apex code can be called from a flow using one of two flow elements: Apex Plug-in and Call Apex Note: Bulk operations are supported by @InvocableMethod annotation but not Process.Plugin interface.

Apex and Process Builder

Apex code can be invoked from Process Builder to add custom functionality to a process.

Database Methods

Apex contains the built-in Database class, which provides methods that perform DML operations and mirror the DML statement counterparts. These Database methods are static and are called on the class name: Database.insert() Database.update() Database.upsert() Database.delete() Database.undelete() Database.merge()

Variables, Constants, and Expressions - Variable

Apex is a strongly-typed language where the data type must be declared before a variable can be used.

Using Properties for Getter and Setter Methods

Apex properties can be used instead of defining getter and setter methods to reduce the amount of code.

Manage Apex Trigger Subscriptions

Apex trigger subscriptions can be suspended or resumed in Platform Events in Setup. When a suspended subscription is resumed, events published during the suspension can still be received.

For which three items can a trace flag be configured?

Apex trigger, Apex Class, user Bad answer: Process Builder, VF page

Potential for Recursion and Cascading

Apex triggers and workflow rules can result in cascading and recursion.

Testing Flows with External Services

Apex unit tests can also be created for flows that use an invocable action with External Services. The HttpCalloutMock interface can be used to simulate the callout to the external service endpoint.

How do you run an Apex Class in developer console?

ApexScenarios class = new ApexScenarios(); class.ApexScenarios(); class name: ApexScenarios{} Method name: ApexScenarios{}

Which component is not subject to the component's hierarchical setup?

Application event

Flavors of Async Apex

Asynchronous Apex comes in a number of different flavors. We'll get into more detail for each one shortly, but here's a high-level overview. It's also worth noting that these different types of asynchronous operations are not mutually exclusive. For instance, a common pattern is to kick off a Batch Apex job from a Scheduled Apex job.

What can flow async paths be used for?

Asynchronous paths can be used to update external objects, perform a callout to an external system, execute a set of actions that do not require to be completed in the current transaction, etc.

A custom record page for the Case object contains three unrelated Aura components: 1. caseList.cmp 2. caseCreate.cmp 3. caseUpdate.cmp. a) The caseList.cmp component shows a list of all the cases assigned to the agent who is currently logged in b) The caseCreate.cmp allows an agent to create a new case by specifying case details and clicking a button c) The caseUpdate.cmp component allows an agent to search for an existing case and update the case by specifying new field values and clicking a button When a new case is created or an existing case is updated, the records displayed in the caseList.cmp component should be updated automatically, and a message should be displayed.

Application events can be utilized for this requirement since the components that need to communicate with each other are not in a containment hierarchy. When a new case is created, the caseCreate.cmp component can fire an application event that can be handled by the caseList.cmp component. Similarly, when a case is updated, the caseUpdate.cmp component can fire an application event that can be handled by the caseList.cmp component. The caseList.cmp component can update the list of records and display a suitable message based on the event.

Application Event

Application events follow a traditional publish-subscribe model. An application event is fired from an instance of a component. All components that provide a handler for the event are notified.

Search Query Method

Aside from using the FIND clause, the query() method of the Search class can also be used to perform SOSL queries. String q = 'FIND {United} IN ALL FIELDS RETURNING Account(Id,Name,Type), Contact, Opportunity, Lead'; List<List<sObject>> results = Search.query(q);

What's an alternate way to handle Apex errors and not using exceptions?

Assertions - e.g., System.assert calls

Use Component in Lightning App Builder

Before an Aura component can be used, for example, in Lightning App Builder or added to a Lightning page, it must implement one of what is called an interface. 1. Interface: An "interface" is used to provide certain functionality or properties to an Aura component. A "user interface" represents a graphical user interface that users interact with.

Which triggers are executed during the execution of a workflow rule that contains a field update ins the Save Order of Execution?

Before and after triggers

Can an application event affect performance?

Behavior may affect performance in certain use cases since the event is broadcast to all the components in the application.

Whenever operating on a value, check to ensure that it is not null to avoid null pointer exceptions and fatal errors

Best practice

Apex Primitive Data Types - 1

Booleans needs to be explicitly set to true or false, otherwise, they are null.

What happens when you encounter a catchable exception?

Both catch and finally statements being executed when the try statement encountered an error.

The uiRecordApi Module

Built on top of Lightning Data Service, the uiRecordApi module includes wire adapters and APIs that can be used to process records without writing Apex code. Some of the functions are summarized below.

What are some examples of bulk operations that can be handled with bulk triggers?

Bulk triggers can handle bulk operations like: Data import Bulk API calls Mass actions Recursive Apex methods/triggers

Security Scenario A developer has defined a quick action for the Account detail page. It invokes a flow that uses an Apex class to execute operations like updating the value of some custom fields on all the related contact records. However, these operations are performed for all the records, even if the current user does not have the permission to view them. publicclassFlowClass {@InvocableMethodpublicstaticvoidprocess() {// read/write data... }}

By default, an Apex class has the ability to read and update all the data in the org, regardless of the sharing permissions of the current user. In order to ensure that the class uses the security sharing permissions of the current user who is logged in, the 'with sharing' keyword can be added to the definition of the Apex class. public with sharing class FlowClass {@InvocableMethodpublicstaticvoidprocess() {// read/write data... }}

Disabling Escape on Visualforce Tags

By default, nearly all Visualforce tags escape the XSS-vulnerable characters. It is possible to disable this behavior by setting the optional attribute escape="false". For example, the following output is vulnerable to XSS attacks: <apex:outputText escape="false" value="{!$CurrentPage.parameters.userInput}" />

How can Flow hide unnecessary fields on a screen?

By using the component visibility settings on a screen component

Invocable Methods and Variables

Certain considerations apply to the use of invocable methods and variables: 1. Data types: Invocable methods and invocable variables support generic sObjectand List data types. 2. Reusable action: Support for sObject data types enables an Apex action to be reused across multiple types of objects 3. Category: Invocable methods can be categorized in Flow Builder by setting the category parameter in the annotation

Test Utility Classes

Common test utility classes are public test classes that contain reusable code for test data creation

SOQL Comparison Operators - 1

Comparison operators are used in field expressions to define the field condition in a where clause.

Confirm, but it appears that you cannot put logic directly in the class; needs to be inside a method

Confirm

Database Class Methods - CONVERTLEAD

Converts a lead into a business account, contact, and opportunity (optional) by passing in lead records. A lead can also be converted into a business account and person account (instead of a contact) simultaneously if an org meets a required configuration.

Additional Flow Considerations - Formula Variables

Creating complex formulas using formula variables should be avoided as this affects performance of the flow.

Cross-Site Request Forgery (CSRF)

Cross-Site Request Forgery (CSRF) flaws are less of a programming mistake as they are a lack of a defense. The easiest way to describe CSRF is to provide a very simple example. An attacker has a Web page at www.attacker.com. This could be any Web page, including one that provides valuable services or information that drives traffic to that site. Somewhere on the attacker's page is an HTML tag that looks like this: <img src="http://www.yourwebpage.com/yourapplication/[email protected]&type=admin....." height=1 width=1 />

Cross-Site Request Forgery

Cross-site request forgery (CSRF) performs an action via a URL that takes advantage of the active session of an authenticated user. 1. Re-direct users: An attacker includes a URL on their site that performs an action on a second site 2. Perform actions: If the user is still authenticated to the second site, the action may be successful, if there is no protection

Cross-Site Scripting (XSS)

Cross-site scripting is when malicious content such as JavaScript / VBScript / HTML is inserted into a web page and executed.

Custom Lightning Components

Custom Lightning components can be built and added to a Lightning page. However, to make a custom Lightning component usable in the Lightning App Builder and Lightning pages, the component and its component bundle must be configured so that they are compatible. My Domain must also be deployed in the org.

Custom Lightning Components - 1

Custom Lightning components can be built using the Lightning Component framework which includes a set of prebuilt self-contained and reusable components.

What can be added to a console to display a VF page?

Custom console component to the sidebar or footer

How are custom exceptions created?

Custom exceptions are created by extending the built-in Exception class.

Custom Exceptions

Custom exceptions can be used to deliberately throw and catch exceptions in methods.

Implications for the Detailed Record in a M/D relationship

Custom objects on the detail side of a master-detail relationship are unable to use sharing rules, manual sharing or queues, as the Owner field is required

Custom Settings

Custom settings enable application developers to create custom sets of data for an organization, profile, or specific user.

A data import file containing 60,000 Contact records need to be processed in the org. It is required that no workflow rule or process be triggered during the import

Data Import Wizard can process only up to 50,000 records at a time. However, it is the only data import tool that is capable of preventing workflow rules and processes from being triggered during an import. The data can then be split into two batches so that the Data Import Wizard can be used.

DML vs. Database Operations

Database Methods 1. Use Database methods instead of DML statements if you want to allow partial success of a bulk DML operation by setting the opt_allOrNone argument to false. 2. Database methods also support exceptions if not setting the opt_allOrNone argument to false. DML Statements 3. Use the DML statements if you want any error during bulk DML processing to be thrown as an Apex exception that immediately interrupts control flow and can be handled using try/catch blocks. 4. This behavior is similar to the way exceptions are handled in most database procedure languages

The Database methods return result objects containing success or failure information for each record. For example, insert and update operations each return an array of Database.SaveResult objects

Database.SaveResult[] results = Database.insert(recordList, false);

Database method example This is how you call the insert method with the allOrNone set to false.

Database.insert(recordList, false);

Which statement should be used to allow some of the records in a list of records to be inserted while others can fail to be inserted?

Database.insert(records, false)

SOQL Date Values

Date and DateTime field values can be used in SOQL queries to filter returned data. Here are some examples and considerations. 1. Date Format: When using dates in a query, the date format followed is YYYY-MM-DD. Example: SELECT Name FROM Contact WHERE Birthdate = 1980-12-06 2. No Quotes: Date or DateTime field values in queries should not be enclosed in quotes (as shown in the above example) 3. Time Standard: DateTime fields use the Coordinated Universal Time (UTC). Offsetting may be required to adjust the value to a local or preferred time zone. Example: WHERE CreatedDate < 2021-01-01T00:00:00+08:00

Bits and Variables

Decimal: An arbitrary precision number and automatically assigned to Currency fields. Double: A 64-bit number that includes a decimal point Integer: A signed 32-bit number without a decimal point Long: A 64-bit number without a decimal point

Limit on Heap Size

Definition: Heap size in actual is the count of memory used by the variables, object instances in an Apex class. In order to store these objects & variables, memory is allocated in Salesforce which is derived from allocated Heap. There is a limit enforced on the total heap size generated during a single transaction. Heap size is the amount of memory allocated to an object during a transaction: 1. Total Heap Size: The Apex heap size limit for synchronous and asynchronous transactions is 6MB and 12MB respectively 2. Example: A list collection is used for storing the results of a SOQL query. The memory allocated for the variable grows exponentially as more and more records are added to the collection. 3. Outcome: If the call is synchronous and the memory allocated for the variable (or total combined heap size of all objects) exceeds 6MB, then the limit exception is thrown.

Rules of Conversion

Depending on the data types used in an assignment statement, there are cases where explicit conversion is not required. 1. Explicit conversion: In general, Apex requires explicit conversion of one data type to another. For example, using String.format, String.valueOf, or casting a variable to String before assigning it to a String data type variable. 2. Implicit conversion: Lower numeric types can be assigned to higher numeric types without explicit conversion. So, directly assigning an Integer to a Decimal is allowed, but the doing the opposite will throw an error.

Apex Enterprise Patterns

Enterprise Design Patterns have been around for a while to represent best practices for large scale development projects. First promoted by Martin Fowler in 2003 - "Patterns of Enterprise Application Architecture". First Adapted to Salesforce by Andy Fawcett in 2014 - now known as "Salesforce Lightning Platform Enterprise Architecture, 3rd edition"

What happens if the following code is written? List<Lead> standardFields = [SELECT FIELDS(CUSTOM) FROM LEAD LIMIT 1];

Error is thrown when Apex attempts to perform an unbounded query. Note: In Apex, cannot use FIELDS(CUSTOM) or FIELDS(ALL)

Customize Entry and Exit Conditions

Evaluation flows can be added in an orchestration to customize the criteria when a stage and interactive steps starts and completes.

Event-Drive Software Architecture - 1

Event-Driven software architecture utilizes event-drive no message-driven architecture which consists of event producers, event consumers, and channels.

Events

Event-driven programming is used in many languages and frameworks, such as JavaScript and Java Swing. The idea is that you write handlers that respond to interface events as they occur. A component registers that it may fire an event in its markup. Events are fired from JavaScript controller actions that are typically triggered by a user interacting with the user interface. There are two types of events in the framework: 1. Component events are handled by the component itself or a component that instantiates or contains the component. 2. Application events are handled by all components that are listening to the event. These events are essentially a traditional publish-subscribe model. You write the handlers in JavaScript controller actions.

Events in Lightning Web Components

Events can also be fired and handled in Lightning web components

A Visualforce page allows users to delete a contact by passing the record Id of the contact as a URL parameter. The page and its custom controller contain the following code: <apex:pagecontroller="CustomController"action="{!init}"></apex:page> publicclassCustomController {publicvoidinit() {Idid = ApexPages.currentPage().getParameters().get('id');Contactc = [SELECT Id FROM Contact WHERE Id = :id];deletec; }} However, the page is vulnerable to a CSRF attack. For example, if a user visits the web page of an attacker while being authenticated with Salesforce, the attacker can easily delete a contact record.

Every VF form includes an anti-CSRF token as a hidden form field that can prevent a CSRF attack. However, in this particular case, the init() method is called before the Visualforce page is rendered in the user's browser. In order to prevent the attack, the action attribute should be removed from apex:page. The apex:commandButton component can be added to the page so that users are required to click a button to delete a particular contact record. The action attribute can be added to the component and associated with the Apex method in the custom controller that deletes the contact record. <apex:pagecontroller="CustomController"><apex:form><apex:commandButtonaction="{!init}"/></apex:form></apex:page>

Limit Exceptions

Exceeding governor limits halts processing of code and causes LimitException which cannot be caught using exception handling.

Exception Handling

Exception handling in Apex can be implemented using try, catch, and finally blocks. These blocks allow code to handle and recover from exceptions.

Assert Exceptions

Exceptions thrown due to the failure of assertion statements like System.assert cannotbe caught.

Which code is not stored in metadata but can be compiled and executed?

Execute Anonymous Block

SOSL example

FIND {test} RETURNING Account (Id, Name, Rating, Type ORDERBY Id DESC)

What log level you need to access SOQL queries?

FINEST

A custom field that is being referenced in Apex can be deleted.

False

Apex test methods have access to pre-existing data in the organization.

False. 1. By default, Apex test methods don't have access to pre-existing data in the organization. You must create your own test data for each test method. 2. Test data isn't committed to the database and is rolled back when the test execution completes. 3. This means that you don't have to delete the data that is created in the tests. 4. When the test finishes execution, the data created during test execution won't be persisted in the organization and won't be available

A VF page cannot be used in Classic if it has been configured to work in Lightning.

False. A VF page accessed in Salesforce Classic uses theclassic styling even withlightningStylesheets set to true.

You can reference any type of formula field within a roll up summary field

False. Automatically derived fields, such as current date or current user, aren't allowed in a roll-up summary field. Forbidden fields include formula fields containing functions that derive values on the fly, such as DATEVALUE, NOW, and TODAY. Formula fields that include related object merge fields are also not allowed in roll-up summary fields. The field being rolled up cannot be a formula field that contain dynamic date functions such as NOW() and TODAY().

Data may be saved multiple times in a single transaction and database commit will also be executed multiple times.

False. Data may be saved multiple times in a single transaction, but a database commit will be executed one time only.

You can put orchestration and related flows in the same change set.

False. Flows need to be activated before the orchestration is deployed. For this reason, separate change sets must be used for an orchestration and its associated flows

When uploading data with data loader, a record will fail if you include a non-existing value for a restricted picklist field.

False. If picklist values do not exist, the record is still imported, but the value is not added to the picklist values and cannot be selected for other records

Salesforce supports static Apex classes.

False. In Apex, you can have static methods, variables, and initialization code. However, Apex classes can't be static. You can also have instance methods, member variables, and initialization code, which have no modifier, and local variables.

Lighting Web Components use component and application events.

False. Lightning Web Components do not use Component and Application Events. Instead, they use standard browser DOM events (or custom events) for communicating up the containment hierarchy

Apex classes can have more than one invocable method.

False. Only a single method in an Apex class can have the @InvocableMethod annotation, and other annotations cannot be used with it.

You need to write unit tests to push flows.

False. Only need to do so for Apex.

You can use describeSObjects method to retrieve information about records

False. The describe information provides details about objects and not records.

When an Apex batch transaction fails, all batch transactions are rolled back.

False. When a batch transaction fails, all the other successful batch transactions will not be rolled back.

A VF page must use a standard or custom controller.

False. You can use global variables in VF page. <apex:page > User Name: {!$User.FirstName} {!$User.FirstName} </apex:page>

Salesforce support Currency variables in Apex

False. You have to use a decimal variable

Programming Models

Features that were not available as a web standard before led to the building of custom frameworks into the Aura model. In 2019, the web standards evolved which enable LWC to depend on lesser custom frameworks

Fire Component Events

Fire a component event to communicate data to another component. A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event.

Which field types cannot be used in formula fields?

Formula fields cannot use long text area, encrypted or Description field

What happens if an exception is uncatchable and you have a try/catch block?

However, if the exception type is uncatchable, then catch blocks as well as the finally block are not executed.

Which function can be used to retrieve third-party images on a VF page?

IMAGEPROXYURL

Which function can a developer use to securely fetch images that are outside an org's server and prevent them from requesting user credentials?

IMAGEPROXYURL()

What happens if governor limit is exceeded to DML operations?

If a governor limit exception is raised, DML is rolled back.

What happens if governor limit is exceeded during an Apex transaction?

If a governor limit is exceeded, the Apex code terminates, and a runtime exception that cannot be handled is issued.

Key Point

If a screen flow executes an invocable method that performs a callout, the callout=true attribute can be added to the annotation. Doing so enables the screen flow to avoid callout errors when the flow also executes DML operations.

What happens if a trigger throws an unhandled exception?

If a trigger ever throws an unhandled exception, all records are marked with an error and no further processing takes place.

Simple and Complex Use Cases - 1

If a use case is simple, declarative customization can be used. Generally, programmatic customization is involved if a use case is complex.

Data Access Control - Omitted Declaration

If an Apex classis used as the entry point to an Apex transaction, an omitted sharing declaration runs as 'without sharing'. Using the 'inherited sharing' keyword ensures that the default is to run as 'with sharing'.

Record or Object Awareness

If an Aura component needs to retrieve the Id or object API name of the record in a Lightning record page where it is added, the following interfaces can be used.

Where do you place WITH SECURITY ENFORCED?

Insert the WITH SECURITY_ENFORCED clause: 1. After the WHERE clause if one exists, else after the FROM clause. 2. Before any ORDER BY, LIMIT, OFFSET, or aggregate function clauses.

What happens if you don't specify a record owner, when uploading data with Data Loader?

If the owner is not specified, it defaults to the person importing the data.

When debugging flows, what does selecting the 'show details of what's executed and render flow in Lightning runtime' option do?

If this option is enabled, the data element's limit consumption and DML and SOQL query activity is displayed in the debug details.

Business Accounts/Person Accounts - VF

If your org uses person accounts: 1. When referencing an account record's name field with a custom controller using the <apex:inputField> component you must specify isPersonAccount in your query. 2. If you create a new account and set name, the record will be a business account. If you create a new account and set lastname, it will be a person account. 3. As a best practice, create a custom name formula field that will render properly for both person accounts and business accounts, then use that field instead of the standard field in your Visualforce pages. 4. f you plan on including your Visualforce page in a Salesforce AppExchange package, in your controller or controller extension, you cannot explicitly reference fields that exist only in a person account.

Additional Apex Scenarios A developer is asked to write an application for calculating house rental subsidy for its employees. The conditions are such that: 1. If an employee's salary is lesser or equal than a certain minimum amount, the rate of 7.5% is used in calculating the subsidy amount. 2. If the salary is between the minimum and a certain maximum amount, 5% is used. 3. If greater than the maximum amount, the rate is 2.5%. However, if the employee has been with the company for more than a certain number of years, 10% is applied regardless of the salary amount earned by the employee.

If, for instance, the minimum amount is 1,000 and the maximum amount is 2,000, the logic can be executed using if-else statements.

Before triggers and DML (really important point)

In Before triggers, the records are not committed in database so we can skip the DML as whatever value we give to records will naturally assigned to database.

Flow: Subscribing to platform events - 1

In Flow Builder, a platform event-triggered flow can be created to subscribe to a platform event. The Platform Event object is specified in the Start element of the flow.

Visualforce Expression Syntax

In Visualforce pages, all content that is encapsulated in {! and } characters is evaluated as an expression. Dot notation is used to access fields or traverse related objects.

What can you use within a Lighting Component to subscribe and receive event messages?

In a Lightning component, the empApi component can be used for subscription and receiving event messages.

Creating and Dispatching Events

In a Lightning web component, a custom event can be created by calling the CustomEvent()constructor.

Access Prior Values of a Record

In a record-triggered flow, the field values of the record before it triggered the flow can be accessed using the $Record__Prior global variable

Updating Records in Schedule-Triggered Flows

In a schedule-triggered flow, the $Record global variable is used to update the batch record

Controlling Revisited Screen Component Values

In a screen flow, the values entered by a user in a Lightning component on a screen can be refreshed or retained when the user revisits the screen.

Rules of Conversion - STRING & ID TYPES

In addition to numeric types, other data types can be implicitly converted such as: 1. A variable of ID data type can be assigned to a String 2. Strings can be assigned to an ID, but because ID validation will execute at runtime, an exception may be thrown if the value is not a valid ID 3. As such, the instanceOf keyword can be used to test if a string is valid ID.

Subscribing to Platform Events - 2

In an event process, a platform event and object is associated in the process' trigger

Variables that are declared with the specific sObject data type

In contrast, variables that are declared with the specific sObject data type can reference only the Salesforce records of the same type.

Sharing Modes - System Context

In general, Apex code runs in system context by default which allows it to have access to all data in the org. 1. No Restrictions: In system context, object permissions, field-level security, and sharing rules of the current user are ignored 2. Full Data Access: In system context, all objects and fields can be accessed and enables Apex code to modify all data.

Inherited Sharing

In inherited sharing, the sharing mode is determined by the calling class or how the Apex class is used 1. Inherits Sharing Mode: For example, if a class that respects sharing rules calls a class that uses inherited sharing, then the called class will also respect sharing rules. 2. Runs as With Sharing: A class that uses inherited sharing will run as with sharing when used as: a) Visualforce or Lightning component controller b) an Apex REST service c) entry point to an Apex transaction

In what ways can VF page be embedded?

In page layout and on Lightning pages using the Visualforce component

Regarding Aura Components

In practice, a Lightning component's code cannot directly interact with its parent and vice versa. A parent component cannot manipulate its children or siblings as with standard JavaScript and the DOM. Inter-component communication must be specified by the developer.

Execution Context

In the Lightning Platform world, code executes within an execution context.

In the Lightning UI, where should a developer look to find information about a Paused Flow Interview?

In the Paused Interviews section of the Apex Flex Queue

Using a Relationship to Avoid a Query Example

In the SOQL query that is used to retrieve accounts, a subquery is added to also fetch related opportunities. Counts as one query, instead of 2. Example: SELECT Id, Name, (SELECT Id, Name, Amount, StageName FROM Opportunities) FROM Account WHERE Id IN :accountIds

Before Update Trigger Example

In this example, a before update trigger is used to assign the record to another owner whenever the value of its "Status" field is changed. Key code on how to get the previous value of the record: Request__c oldRequest = Trigger.oldMap.get(newRequest.Id);

getCompleteResult()

Indicates whether there are more records in the set than the maximum record limit. If this is false, there are more records than you can process using the list controller. The maximum record limit is 10,000 records.

generateVerificationUrl(policy, description, destinationUrl)

Initiates a user identity verification flow with the verification method that the user registered with, and returns a URL to the identity verification screen. For example, if you have a custom VF page that displays sensitive account details, you can prompt the user to verify identity before viewing it.

Instance methods, member variables, and initialization code

Instance methods, member variables, and initialization code have these characteristics: - They're associated with a particular object - They have no definition modifier. - They're created with every object instantiated from the class in which they're declared.

Which data types are supported by a switch statement expression?

Integer, Long, sObject, String, and Enum

How can you use a loop to iterate over a list or set?

Integer[] myInts = new Integer[]{10,20,30,40,50,60,70,80,90,100}; for (Integer i: myInts) { System.debug(i); }

What access modifiers can you uses with interface methods?

Interface methods have no access modifiers. They're always global. For more information, see Interfaces.

Visualforce Controllers Overview - Controller Extensions

Invoked using the extensions attribute of the <apex:page> component

Visualforce Controllers Overview - Standard Controllers

Invoked using the standardController attribute of the <apex:page> component

By default, the allOrNone parameter is true, which means that the Database method behaves like its DML statement counterpart and will throw an exception if a failure is encountered.

Key Point

How to build an efficient flow

It is a good habit to always think about how to make your flows more efficient. By following these practices, you may not even encounter the problem of hitting the limits: - Avoid overusing data elements. - Try not to use data element in loop. - Skip the loop if possible. - Make entry criteria strict. - Utilize variables and Assignment element for updating records.

How can you subscribe to platform events within Salesforce?

It is possible to subscribe to and receive platform events in Salesforce using processes, flows, Apex triggers, and custom Lightning components.

A List or Iteration For Loop

Iteration For Loop, is used to traverse a list or set without knowing the size of the collection.

Which function encodes text and merge field values by inserting escape characters before unsafe JavaScript characters?

JSENCODE

What is used to exchange data between client/server in Lightning Components?

JSON (JavaScript Object Notation) format is used to exchange data between client and server.

Note that there are instances when a failed flow interview will not be saved: 1. Flow is triggered by a platform event or an Apex test method 2. Flow's metadata status field is Draft/InvalidDraft 3. Flow is a standard flow or part of a managed package and 4. Error is handled using a fault path or is triggered after a paused flow

Key Point

The block where a variable is declared determines the scope of that variable. A variable will be available to its sub-blocks, but a variable declared in a sub-block will not be available to its parent block.

Key Point

Apex provides the generic Exception class plus 24differenttypesof built-in exceptions in the System namespace.

Key point

By encapsulating the input fields within <apex:pageBlock> and <apex:pageBlockSection> components, VF automatically inserts field labels ("Account Name", "Industry") as well as indicators of whether values are required for the fields, all using the platform styles.

Key point

Exceptions note errors and other events that disrupt the normal flow of code execution. throw statements are used to generate exceptions, while try, catch, and finally statements are used to gracefully recover from exceptions.

Key point

Future methods can't be used in Visualforce controllers in getMethodName(), setMethodName(), nor in the constructor.

Key point

Order catch statements from specific to generic. All exceptions are considered to be of type Exception, so if you catch the generic Exception type first, the other catch statements won't execute—only one catch block executes.

Key point

The valueOf() enum method can be used to convert a specified string to an enum value. If the string does not match an enum value, an exception will be thrown.

Key point

To subscribe an Apex trigger to a platform event, an after insert trigger is created on the Platform Event object, which in this example, is the Order_Event__e. Note that platform events only support after insert events. An Apex trigger can be used to subscribe to a platform event message.

Key point

When using assert methods, an exception is thrown to indicate a failed test when the actual result does not match the expected result.

Key point

Formula fields do not support Long/Rich/Encrypted Text Area fields; custom formula fields are not available in web to lead forms or web to case forms.

Key point.

If you're dealing with a string variable, Apex is case sensitive (blue and BLUE are considered two different values)

Key point.

By default, every parent (LWC) in the containment hierarchy can't handle an event during the capture and bubble phases. Instead, the event propagates to every owner in the containment hierarchy.

Key point. A Lightning component hierarchy does not behave like a DOM tree. By default (we get to the exceptions later), only parent components that create subcomponents (either in their markup or programmatically) can handle events. This singles out container components.

A developer is trying to update the status of leads based on their source (LeadSource). The logic for the update is as follows: If the lead source is 'eCommerce,' update the status to 'MQL.' If the lead source is 'Referral,' update the status to 'SQL.' For other lead sources, update the status to 'Marketing Lead.' Modify the placeholder code to satisfy the requirement.

Key point: didn't have to put the individual account back into the list; the DML statement was on the list

A List iteration helps prevent exceeding the heap size limit when handling large volumes of data. Note, however, that version 3 will also fail if there are more than 10,000 records. If so, Limit methods, for example, should be used to prevent failures.

Key term

Types of Flow - Record-Triggered Orchestration

Launches when a record is created or updated.

Types of Flow - Record Triggered Flow

Launches when a record is created, updated, or deleted. This Autolaunched flow runs in the background.

Types of Flow - Autolaunched Orchestration (No Trigger)

Launches when invoked by Apex, REST API, and more.

Types of Flow - Autolaunched Flow (No Trigger)

Launches when invoked by Apex, processes, REST API, and more. This Autolaunched flow runs in the background.

Defining a Target Component

Lightning App Builder is required to select the target components for exposed events of a source component. Dynamic Interactions is supported only on Lightning App pages. When a component has exposed events, an Interactions tab will appear in its properties panel. This tab lists the exposed events and is used to define the target components for each event. To target a component, the Add Interaction button is clicked.

Lightning Message Service

Lightning Message Service is a service which enables the following technologies to communicate with each other within a single Lightning page or between multiple Lightning pages.

Lightning Out

Lightning Out is a feature that extends Lightning apps. It acts as a bridge to surface Lightning components in any remote web container. This means you can use your Lightning components inside of an external site (for example, Sharepoint or SAP), or even elsewhere on the platform such as on Heroku.

JavaScript API Distortion

Lightning Web Security prevents unsafe behavior by altering running code in the JavaScript sandbox. This technique is called "distortion" and dynamically modifies code at the JavaScript API level in order to

How does LWS secure Lightning Web Components from different namespaces?

Lightning Web Security secures Lightning web components from different namespaces by isolating the components from each other through what is called as virtualization.

Lightning Web Components

Lightning components can also be created using the Lightning Web Components (LWC) model, which uses the core Web Components standards. HTML and modern JavaScript can be used to build Lightning web components.

Modular Components

Lightning components, which are either Aura component sor Lightning web components, are modular, interoperable, reusable units. Here are some key points to remember.

Types of events for Lighting components

Lightning web components can communicate across the DOM using a publish-subscribe pattern where one component publishes the event and subscribing components receive the event.

Flow and Process Limits

Like Apex, a transaction that is invoked by a flow or process is subject to governor limits. When building solutions using these tools, the following limits should be considered.

Additional Flow Considerations - DML Operations

Like DML statements inside for-loop statements in Apex, placing an Update Records element, for example, inside a For Loop element in a flow should be avoided.

Use Limit Methods

Limit methods such as Limits.getDMLRows() and Limits.getLimitDMLRows() can be used to obtain information regarding governor limits

What two considerations should a developer new to Salesforce be aware of?

Limits are enforced on shared resources (Governor Limits). Code cannot be deployed into production unless test code coverage is achieved.

Which class should be used to output debug messages for governor limits to determine if or when the code is about to exceed governor limits?

Limits class

Best Practices and Considerations - DML Limits

Limits.getDMLRows() can be used together with the getLimitDMLRows() method which returns the actual limit

Best Practices and Considerations - DML Rows

Limits.getDMLRows() counts the number of records that have been processed with any statement that counts against the DML limits.

A custom object called Commission__c has been created with a lookup relationship field named "Opportunity", which is used to reference the opportunity that commissions are related to. A SOQL query has been created that returns the Type and Amount fields of the commission records that belongs to the current logged in user. Modify the query such that the results also include the name of the related opportunity after the Amount__c field in the SOQL statement.

List<Commission__c> records = [SELECT Type__c, Amount__c, Opportunity__r.Name FROM Commission__c WHERE OwnerId = :UserInfo.getUserId()];

Apex Scenario A developer is creating an Apex class that should retrieve all the contacts who are VP and change the value of the 'Email' field on each contact record to the value of the 'Email__c' field specified on the contact's parent account record. A SOQL query needs to be written for this use case.

List<Contact> contacts = [SELECT Email, Account.Email__cFROM Contact WHERE Title = 'VP'];

Syntax to determine if a list is empty

List<Contact> results = [SELECT MailingCity FROM Contact WHERE Id = :c.Id AND MailingCity = 'San Francisco' LIMIT 1]; if(!results.isEmpty()){} Note: make sure to initialize string and include that in the systax if(results != null && !results.isEmpty()){}

What are two ways to declare a list?

List<Integer> myList = new List<Integer>(); List<String> myStrings = new List<String> { 'one', 'two' }; Integer[] myList = new List<Integer>();

How can you retrieve all the picklist values using Apex?

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

Performing nested SOQL

List<sObject> results = [SELECT Id, (SELECT Id FROM CONTACTS LIMIT 2) FROM ACCOUNT LIMIT 2];

Similarly, you can get the child sObjects of an sObject using the same syntax. The only difference is that you now have a collection of one or more sObject child records, while in the previous case there is only one parent record.

List<sObjectTypeName> children = objectA.ChildRelationshipName;

Local variables

Local variables have these characteristics: - They're associated with the block of code in which they're declared - They must be initialized before they're used

Logical Operators

Logical operators can be used in a WHERE clause to connect field expressions, and/or negate the result of a field expression.

Declare a map variable named 'countryCurrencyMap' using a single line of code. Each key in the map should represent a unique country that maps to the country's currency. The variable should contain the following key-value pairs: 'US' : 'USD' 'France' : 'EUR' 'Australia' : 'AUD'

Map<String, String> countryCurrencyMap = new Map<String, String>{'US' => 'USD', 'France' =>'EUR', 'Australia' => 'AUD'};

When using M/D relationship, what is one reporting implication?

Master-detail relationships allow data from three objects to be joined in one report: the master object, the detail object, plus one other lookup object (lookup on master or detailed side?)

@TestSetup Annotation

Methods defined with the @testSetup annotation are used for creating common test records that are available for all test methods in the class. Test setup methods are defined in a test class, take no arguments, and return no value. The following is the syntax of a test setup method. @testSetup static void methodName() { }

What access modifiers do Apex methods need so that they can be called by JavaScript remoting?

Methods to be called by JavaScript remoting, called Remote Actions, must be either global or public.

Where can the INCLUDES / EXCLUDES SOQL comparison operators be used?

Multi-select picklists only

An Apex interface and Apex class, namely MyInterface and MyClass respectively, exists in the org. Another class called MyExtendedClass, which should be accessible publicly, needs to be created that should implement MyInterface but also extend from MyClass to inherit its methods and properties. How should the MyExtendedClass Apex class be declared?

Note that the class extension is done first and the the implementation of the interface

What's one implication of using the isChanged operator when using Decision elements?

Note that whenever the Is Changed operator is used, the "When to Execute Outcome" setting will be automatically fixed to "If the condition requirements are met

Anonymous Apex Blocks

Note the following about the content of an anonymous block (for executeAnonymous(), the code String): 1. Can include user-defined methods and exceptions. 2. User-defined methods can't include the keyword static. 3. You don't have to manually commit any database changes. 4. If your Apex trigger completes successfully, any database changes are automatically committed. If your Apex trigger does not complete successfully, any changes made to the database are rolled back. 5. Unlike classes and triggers, anonymous blocks execute as the current user and can fail to compile if the code violates the user's object- and field-level permissions.

QueryException

Occurs when there is a problem with a SOQL query

NoAccess Exception

Occurs when there is a problem with unauthorized access, such as trying to access an sObject that the current users does not acces to

What's one benefit of casting generis sObjects as specific sOjbect types?

One of the benefits of doing so is to be able to access fields using dot notation, which is not available on the generic sObject.

When should application events be used?

One should only use an application event for: 1. Events that should be handled at the application level 2. @hen a component needs to communicate with another component that does not belong to the containment hierarchy of the source component

Apex Scenario Cosmic Innovation has more than 10,000 opportunities in Salesforce. When the stage of an opportunity is changed to 'Closed Won', the record should be sent automatically to a REST-based external application that is used for managing sales operations. When the stage of an opportunity is changed to 'Closed Lost', a record of a custom object called 'Lost Sale' should be created automatically.

One way to meet the requirement above with best practices in mind is to handle the record creation for Closed Lost opportunities using a record-triggered flow. As for Closed Won opportunities, the flow can call an invocable method which performs the callout to the external application.

Record-Trigger Flow Triggers - A record is created; a record is updated; a record is created or updated

Optimize flow for: 1. Fast Field Updates: Update fields on the record that triggers the flow to run. This high-performance flow runs before the record is saved to the database. 2. Actions and Related Records: Update any record and perform actions, like send an email. This more flexible flow runs after the record is saved to the database.

Build an Orchestration

Orchestrations are built using the Flow Builder (Setup> Flows>New Flow). Orchestrator tiles contain Orchestrator-specific elements. 1. At least one Stage element is required in an orchestration. Multiple interactive and background steps can be added to a stage. 2. The Decision element performs the function of an if-then statement. It evaluates certain conditions and route users though the process based on the outcome.

Exception Methods - Other Methods

Other than common methods, DMLExceptions and EmailExceptions have additional methods such as getDmlFieldNames and getDmlMessage.

Scenario (Important Flow and Transaction Control) A company in the manufacturing industry uses Salesforce to track their clients and projects and wants to use an external platform for managing their accounting and bookkeeping. When the status of an expense record is updated to a certain value, the record needs to be sent to the external system. A screen flow is being used to save changes to the record. However, when a callout from an invocable method is added to the flow via an Apex Action, the System.CalloutException is encountered

Performing a callout after a DML action in the same transaction is not allowed and throws the "You have uncommitted work pending..." callout exception. Fortunately, an Apex action in a screen flow can be configured using the Transaction Control settings to allow the flow to decide at run time whether it is necessary to perform the action in a separate transaction in order to execute successfully. A callout=true attribute should be added to the invocable method annotation to inform the flow that the Apex method will perform a callout. This configuration enables the screen flow to avoid the callout exception as it will know how to handle the Apex action during the execution.

Database Class Methods - Database Class Methods - EMPTYRECYCLEBIN

Permanently deletes records from the Recycle Bin by specifying a list of sObject or record Ids, or an sObject.

Polyglot Persistence

Polyglot Persistence is a fancy term to mean that when storing data, it is best to use multiple data storage technologies, chosen based upon the way data is being used by individual applications or components of a single application.

Namespace

Prefix when working with an AppExchange app or you want to isolate part of your code

How can you trigger email alerts?

Processes, flows, workflow rules, approval processes, or entitlement processes.

Additional Apex Scenarios A store sells accessories for parties and special events. It prices its balloons based on their colors as there are colors that are more popular, and others that are harder to find, or more expensive to buy from its suppliers. A default price is applied for the rest of the colors. How can this scenario be translated using only one type of control flow in Apex?

Provided that the colors of the balloons and their prices are known, the scenario can be interpreted using a switch statement with multiple literal string values. An when else block is added to the statement to catch the rest of the values. Note that if-else statements can also be used in the scenario above.

Queueable Apex Class - 1

Queueable Apex allows you to add asynchronous jobs to the queue and monitor them. It offers enhancements over using @future methods

A developer is trying to update the email opt-out status of leads coming from Acme. A SOQL query has been created to return the Email and Email Opt Out fields of lead records. Modify the SOQL query so that it only returns lead records with emails ending in '@acme.com'.

SELECT Id, Email, HasOptedOutOfEmail FROM Lead WHERE Email LIKE '%@acme.com'

SOSL

Salesforce Object Search Language: Similar to SOQL but searches for specific text searches within records. Can query multiple objects at a time.

Grouping Unit Tests

Salesforce allows the following groupings of unit tests to be run: 1. Single class 2. Test Suite 3. Multiple Classes 4. All tests

Error 'Apex heap size too large'

Salesforce enforces an Apex Heap Size Limit of 6MB for synchronous transactions and 12MB for asynchronous transactions. The "Apex heap size too large" error occurs when too much data is being stored in memory during processing.

Securing Sensitive Data

Salesforce provides multiple options for securing sensitive data such as passwords, encryption keys, OAuth tokens, etc. 1. Declarative options: Sensitive data can be stored using the declarative features: protected custom metadata types, protected custom settings, encrypted custom fields, and named credentials. 2. Programmatic options: Data can be programmatically secured through encryption and decryption using methods provided by the Crypto Apex class (encryption at rest and in transit)

Roll Up Types

Sum, Min, Max, Count

Enforcing FLS in Apex

Schema.sObjectType.<sObject>.fields.<field> - isAccessible() - isUpdateable()

Lifespan of scratch org

Scratch orgs have a maximum 30 days lifespan. You can select a duration from 1 through 30 days at the time of creation, with the default set at 7 days. After the scratch org has expired, you can't restore it

Flow - Rollback Changes

Screen flows provide a Roll Back Records element which can be used to cancel all pending record changes in a current transaction.

Apex Serialization/Deserialization

Serialization is a process of converting an apex object into stream of bytes so that it can be transferred over a network or stored in a salesforce record. Deserialization is the exact opposite - which convert bytes of stream into object.

What is used for for bulk process of records with trigger?

Sets and maps are used for bulk processing of records.

An insurance company plans to use Salesforce for their employees to access, review, and update insurance application records. A Salesforce administrator has created a Lightning record page for a custom object that is used to store each insurance application, which goes through several stages in the application process. It is required that the application record should only show fields that are necessary on each stage as different stages require different fields and different set of users. This way, users assigned to each stage can only see the fields that are applicable to them and makes the overall process more efficient

Since the application record uses a custom object, Dynamic Forms can be used. The Record Detail component in the existing Lightning record page can be upgraded into a Dynamic Form, which converts the sections and fields into individual Lightning page components. Like any other component in a Lightning page in Lightning App Builder, the components will have their own visibility settings. Then, the field that is used by the application record for determining the stage can be used to define the visibility criteria of each Section Field or Field component.

Accessing Describe Result

The Describe Result of an sObject can be accessed using the getDescribemethod or the sObjectTypestatic variable

What can be added to a lightning page?

Standard, custom, and third-party components can be added to a lightning page. Global actions can be added via the Actions attribute on the Lightning App page properties

Create Data from Static Resources

Static resources and Test.loadData method can be used to populate data in test methods without writing several lines of code.

Static variables

Static variables declared in an Apex class can be directly accessed without instantiating using the following syntax: ClassName.StaticVariableName.

Static Resources

Stylesheet, JavaScript, images, archive files, etc. can be uploaded as static resources and referenced in a Visualforce page by using the $Resource global variable. To access files contained in an archive, the URLFOR function can be used

Subscribe to Platform Event Notifications in a Lightning Component

Subscribe to platform events with the empApi component in your Lightning web component or Aura component. The empApi component provides access to methods for subscribing to a streaming channel and listening to event messages. The empApi component uses a shared CometD-based Streaming API connection, enabling you to run multiple streaming apps in the browser for one user. The connection is not shared across user sessions.

What can be used to create or delete tests that can be run together?

Suite Manager in Developer Console

Where can FIELDS(ALL) and FIELDS(CUSTOM) be used?

Supported in Salesforce CLI and SOAP/REST only if the results rows are limited (such as using LIMIT)

What syntax do you use to get the total number of queries used?

System.debug('Before SOQL - Total Number of SOQL Queries Used' + Limits.getQueries());

What types are available for flow variables?

Text Record Number Currency Boolean Date Date Time Picklist Multi-select picklist Apex-defined

The $Record__Prior global variable is available for which flow types?

The $Record__Prior global variable is available in a record-triggered flow that is configured to run when a record is updated, or when a record is created or updated.

How can you reference static resources in VF Pages that are uploaded as standalone files?

The $Resource global variable and dot notation is used to reference static resources that are uploaded as standalone files. For example, {!$Resource.<resourcename>}.

BUBBLES:TRUE, COMPOSED:FALSE

The 'bubbles: true and composed: false' configuration allows bubbling up the event through the DOM; does not cross the shadow boundary.

BUBBLES:TRUE, COMPOSED:TRUE

The 'bubbles: true and composed: true' configuration can be used to bubble up an event through the DOM, cross the shadow boundary, and continue bubbling up through the DOM to the document root.

<apex:composition>

The <apex:composition> component fetches the Visualforce template page you created earlier, and the <apex:define> component fills the named holes in that template. You can create multiple pages that use the same component, and just vary the placeholder text

.js-meta.xml file

The <component>.js-meta.xml file defines the metadata values for the component, including the design configuration for components intended for use in Lightning App Builder.

JsonAccess Annotation

The @JsonAccess annotation can be defined on an Apex class and control how it can be serialized and/or deserialized, and uses the following parameter values

@RestResource

The @RestResource annotation is used at the class level and enables you to expose an Apex class as a REST resource.

what annotation can you use at the class level to expose an Apex class as a REST resource?

The @RestResource annotation is used at the class level and enables you to expose an Apex class as a REST resource.

Key point about about using * in SOQL

The API names of the objects and fields are used or referenced in a SOQL query. Using an asterisk(*) to select the record fields is not allowed. Not allowed: // the query below is is not allowed! Contact con = [SELECT * FROM Contact LIMIT 1];

Monitoring Queue Jobs with the Flex Queue

The Apex Flex queue enables you to submit up to 100 batch jobs for execution. Any jobs that are submitted for execution are in holding status and are placed in the Apex Flex queue. Up to 100 batch jobs can be in the holding status.

What can you find under the Apex Jobs section in Set Up?

The Apex Jobs page shows all asynchronous Apex jobs with information about each job's execution. The following screenshot shows one future method job and two completed batch jobs for the same Batch Apex class.

Data Access Control - Sharing Behavior

The Apex class that uses the 'inherited sharing' keyword runs as 'with sharing' when used as a Visualforce page controller, Apex REST service, or an entry point to an Apex transaction.

What happens when a field whose value is not specified for an object in an Apex class is made required?

The Apex code throws an exception when it is executed.

ApexPages.message class

The ApexPages.message class can be used to show errors related to exceptions caused by a custom controller or controller extension for a Visualforce page.

Lightning Data Service (LDS)

The Aura framework supports the Lightning Data Service (LDS), which serves as the data layer and can be used to read, create, update, and delete records. Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. Lightning Data Service handles sharing rules and field-level security for you. In addition to simplifying access to Salesforce data, Lightning Data Service improves performance and user interface consistency. At the simplest level, you can think of Lightning Data Service as the Lightning components version of the Visualforce standard controller. While this statement is an over-simplification, it serves to illustrate a point. Whenever possible, use Lightning Data Service to read and modify Salesforce data in your components.

Unique Count in SOQL

The COUNT_DISTINCT() function can be used to return the number of distinct non-null values matching the criteria in the query

BULK DML STATEMENT

The DML statement 'insert ListName' is used to insert multiple records with one operation

Lightning Component Framework - 1

The Lightning Component framework is a UI framework used for building single-page apps with dynamic and responsive user interfaces in the Salesforce platform. 1. Apex and JavaScript: Lightning components built using the Lightning Component framework use HTML, CSS, and JavaScript on the client side and Apex on the server side 2. Programming Models: Custom Lightning components can be built using the Aura Components or Lightning Web Components programming models. They can coexist and interoperate on a page. 3. Stateful and Stateless: It utilizes a stateful client (using JavaScript) and a stateless server (Apex). The client calls the server only when absolutely necessary, which results in fewer calls to the server and more responsive and efficient apps.

Lightning Component framework

The Lightning Component framework uses a stateful client and stateless server architecture that relies on JavaScript on the client side to manage UI component metadata and application data. The client calls the server only when necessary, and the server only sends data that is needed by the user to maximize efficiency. Using JSON to exchange data between the server and the client, the framework intelligently utilizes your server, browser, devices, and network so you can focus on the logic and interactions of your apps.

Events

The Lightning Component framework uses event-driven programming. Lightning Aura components can communicate with each other using events. An event may or may not be triggered by user interaction. 1. Event configuration: Events can be configured to relay data within the containment hierarchy or to all components in the application. Events are fired from JavaScript controller actions. Components with registered event handlers can respond to the events. 2. Event Types: There are two types of events, namely, component events and application events. Both types of events are fired from an instance of a component a) A component event can be handled by the component that fired the event or by a component in the containment hierarchy. b) An application event can be handled by any component that has a handler for the event.

Lightning Message Service

The Lightning Message Service (lightning/messageService) can be used to communicate between components within a single Lightning page or across multiple pages. It supports: 1. Aura components 2. Lightning web components 3. VF pages in any tab or pop-out window in Lightning Experience

Lightning Message Channel

The Lightning Message Service is based on Lightning Message Channels, which is metadata used as an exclusive channel by components to subscribe and publish messages to

Limits Apex class

The Limits class is used to retrieve information for resources that have associated governor limits. The table below shows some of the most common methods in the class.

What is the Navigation Rules options available when using the Console navigation style?

The Navigation Rules option, which is only available when using the Console navigation style, determines whether records are opened as a workspace tab or subtab of another record

Additional Apex Scenarios A developer needs to query a large number of records from the database for processing. How can the records be queried from the database that it avoids potential heap size error and DML governor limits when updating?

The SOQL for-loop can be used to query results that return many records and avoid the limit on heap size. In this type of loop, each iteration will process records in batches of 200. The break control structure can be used to exit the loop and avoid a DML statements governor limit exception

SObjectType Class Methods

The SObjectType class has instance methods to return the describe sObject result for a field and construct a new sObject

SObjectType Class Methods

The SObjectType class has instance methods to return the describe sObject result for a field and construct a new sObject.

Orchestrator and Orchestration Building Blocks - 1

The Salesforce Orchestrator can be used to create an app with multi-step processes that interact with multiple users called Orchestration. An Orchestration is composed of the following: 1. Stages: A stage groups related steps. Stages are executed successively. There can only be one in-progress stage in an orchestration at a time. Exit criteria determines when a stage is considered as complete. 2. Steps: Steps are categorized as either interactive or background. An interactive step is assigned to a user, group, or queue as it requires user interaction. A background step launches an auto-launched flow and requires no user interaction.

Schema Class Methods

The Schema class has certain static methods for obtaining schema describe information.

Schema Namespace Classes - 3

The Schema class has certain static methods for obtaining schema describe information.

Screen Flow Element

The Screen Element is available in a screen flow which enables it to build a user interface that can be used for collecting user input or displaying data

Section Component

The Section screen component can be used to create flow screens with multi-column layouts. The section, which is collapsible, also supports specifying a header text.

Data Access Control - SECURITY.STRIPINACCESSIBLE

The Security.stripInaccessible Apex method can be used to remove fields from SOQL query results that the current user does not have access to and avoid exceptions when a DML operation is performed.

Transaction Finalizer - 2

The System.FinalizerContext interface contains four methods.

Flow Transaction Control

The Transaction Control setting allows three (3) options: 1. Recommended by Salesforce: allows the flow to decide at run time. 2. The second option will always execute the Apex action in a different transaction 3. The third option will always execute the Apex action in the same or current transaction as the flow

Updating Records in Record-Triggered Flows

The Update Records element can be used in a record-triggered flow to update the triggering record.

With Apex Upsert DML, what is used to match the records?

The Upsert statement or Database method uses: 1. The ID of the record as the key to match records 2. A custom external ID field 3. A standard field with the idLookup attribute set to true

LWC Scenarios A certified translation services company is migrating several of their Visualforce pages to Lightning Experience by adding them to a Lightning app page using the standard VF Component in Lightning App Builder. Custom Lightning components also exist in the Lightning app page that are used in their daily business processes. One of the VF pages is integrated with a third-party tool and is used to review and check content for typographical and grammatical errors. A custom Lightning web component is used for easily viewing status reports of processed records in their various review stages. The Lightning component needs to automatically reflect status changes accordingly when the records are updated using the VF page.

The Visualforce page and Lightning web component can use Lightning Message Service to communicate with each other. A Lightning Message Channel metadata can be created which will be used by the components as their communication channel. The VF page can act as the publisher in the message channel. The Lightning web component can subscribe to the channel to receive messages published by the VF page. After a record is processed in the VF page, it can send a message to the channel containing data about the update. The Lightning web component can then receive the message and display status changes accordingly

What is required to override a tab home page with a VF page?

The Visualforce page must use the standard list controller for that tab, a custom controller, or no controller.

SOQL WHERE Clause

The WHERE clause can be used in a query to specify a condition expression that includes one or more field expressions. It is recommended to always use this clause to reduce query results.

SOSL WHERE

The WHERE clause is used to search and only return records that match a specified criteria.

Data Access Control - WITH SECURITY_ENFORCED

The WITH SECURITY_ENFORCED clause, which enforces field and object-level security permissions, can be added to a SOQL statement which will cause the query to throw a System.QueryException if the current user does not have access to a field or object that is referenced in the SOQL statement

SOQL WITH

The WITH clause can be used to filter records based on field values: 1. Filter Criteria: Unlike the WHERE clause, the WITH clause does not only support fields from the object specified in the FROM clause but allows filtering by other related criteria 2. Filter Results: If WITH is specified, the query returns only records that match the filter and are visible to the user 3. Example: this clause can be used to filter Knowledge articles based on one or more data category groups as follows: SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY Product__c AT Desktop__c

SOQL WITH has special use cases

The WITH clause can only be used in the following cases: 1. To filter records based on their categorization. See WITH DATA CATEGORY filteringExpression. 2. To query and retrieve record changes tracked in a user profile feed. See UserProfileFeed in the Object Reference for Salesforce and Force.com.

SOQL Wildcard - _ (underscore)

The _ wildcard matches exactly one character

Example of Starting a Flow from Apex Dynamically

The below illustrates using the dynamicFlowMethod example. This method accepts the namespace, a flow name, and parameters to invoke a flow dynamically.

Component Events - Bubble Phase

The default phase used by a component event is the bubble phase, which behaves in a bottom-up manner. When an event is fired, the source component gets to handle the event first. Next is its parent component, followed by the grandparent, and then each component all the way up until the root component.

Delete Related Records

The delete operation supports cascading deletions. If you delete a parent object, you delete its children automatically, as long as each child record can be deleted.

Schema Method - 1

The describeSObjects Schema method can be used to describe sObjects

Schema Method - 2

The describeSObjects Schema method can be used to describe sObjects. In this example, describe results will be returned for the Account, Contact, and Opportunity objects.

Additional Apex Scenarios A feature in an application needs to perform a process that may fail or succeed. If it succeeds, it will exit the loop and move on. If it fails, it will try again. However, it will stop trying after failing a maximum number of times.

The do-while loop is most suitable in this requirement. If, for instance, the allowed number of retries is 5, the solution, for example, can be written as attached.

Scheduled path example

The example below shows a scheduled path that runs one week after an account record is created.

Retrieve Record Type Id Example

The example method below can be used to retrieve the Id of a record type by specifying the developer name of a record type: returnSchema.SObjectType.Account.getRecordTypeInfosByDeveloperName()?.get(developerName)?.getRecordTypeId();

What Apex DML statements are available?

The following DML statements are available: insert update upsert delete undelete merge Note: Each DML statement accepts either a single sObject or a list (or array) of sObjects.

SOQL Wildcards Examples

The following SOQL statement returns accounts where the Active custom field is true and the name begins with "Uni" that are sorted in descending order according to their names.

Rules for declaring methods

The following describes certain rules and properties for declaring methods in Apex

Approval Processes

The following diagram provides an overview of the capabilities and features of this tool.

Unit Test Limitations

The following features are not supported in unit tests.

Programming Items Not Protected from XSS

The following items do not have built-in XSS protections, so take extra care when using these tags and objects. This is because these items were intended to allow the developer to customize the page by inserting script commands. It does not makes sense to include anti-XSS filters on commands that are intentionally added to a page. 1. Custom JavaScript 2. Formula Tags

Deploying an Orchestration

The following must be considered when deploying an Orchestration

Exceeding Governor Limits

The following occurs when a governor limit is exceeded: 1. Terminated: the current transaction is immediately terminated and is unrecoverable. 2. Limit Exception: The System.LimitException is thrown which is an exception that cannot be handled 3. Rollback: Entire transaction is rolled back and no data is committed to the database.

Interface Definition and Implementation

The following shows how an interface can be defined and then implemented by an Apex class. The class must implement all the methods defined in the interface.

Using Public and Private Access Modifiers

The following shows some example declarations of public and private methods and variables.

Which standard buttons can be overridden with a VF page?

The following standard buttons can be overridden using a Visualforce page.

Which types of Lighting pages can be using using app Builder?

The following types of Lightning pages can be created using Lightning App Builder: app page homepage record page email application pane When creating a Lightning page, a template can be selected, which divides the page into regions.

SOSL IN

The following values can be used in the SearchGroup phrase

Component Events - Capture Phase

The order of the event propagation in the capture phase behaves in a top-down manner. When the source component fires the event, the root component gets to handle the event first and the propagation traverses down the containment hierarchy until it reaches the source component.

Scenario A telecommunications company provides cable, internet, and phone subscriptions to its customers. They would like its sales representatives to be able to easily identify the services that a customer is currently subscribed to and offer timely promotions for renewal or purchase options as to upsell and/or cross-sell their services. The operations manager of the company has requested a user interface that will deliver such features to be available in the org for their team to use

The requirement can be achieved by adding the standard Einstein Next Best Action Lightning Component on a custom Lightning Record page using Lightning App Builder. A strategy can be built based on the status of the customer and the services subscribed, as well as active promotions launched by the company. These variables help determine the recommendations that the user can offer to the customer real-time. Each recommendation is configured to invoke a flow when it is accepted. Additional configuration can be made to invoke the same flow when the recommendation is rejected. The flow can be as simple as sending an email to the customer, or it can be launched as a multi-screen flow that guides the user through a series of steps to complete a process such as availing of a special promotion. The flow can also execute a certain Apex action on recommendation rejection.

An Apex Controller Containing Automatic Properties important slide

The sample controller below shows three properties with different access levels based on their defined accessors.

Save Order of Execution

The save order of execution is a sequence of events that occur when a record is saved in Salesforce.

<apex: detail> in VF

The standard detail page for a particular object, as defined by the associated page layout for the object in Setup. This component includes attributes for including or excluding the associated related lists, related list hover links, and title bar that appear in the standard Salesforce application interface.

What types of flows can you run from Apex?

The start method of the Flow.Interviewclass can be used to run auto-launched or user provisioning flows.

Apex Design Patterns - Strategy Pattern (aka the policy pattern)

The strategy pattern is a behavioral pattern that helps you control dynamic application flow. This pattern allows us to define a family of algorithms through multiple classes which implement an interface. The choice of which implementation to use is determined at runtime.

What happens if a flow attempts to perform a synchronous callout after a DML operation?

The transaction was rolled back due to an error because the flow attempted to perform a synchronous callout after a DML operation, which is not allowed.

Invoking an @future Method in an Apex Trigger

The trigger below will only execute the future method once for all records.

What happens if a trigger with a DML statement triggers itself?

The triggers enters an infinite loop and eventually fails.

DML - Undelete

The undelete DML statement is used for restoring deleted records from the Recycle Bin

What is view state?

The view state is automatically created and used to store state across multiple pages such as in a wizard. The view state holds the state of the components on the page such as field values and has a limit of 170KB.

{! ... }

The {! ... } tells VF that whatever lies within the braces is dynamic and written in the expression language, and its value must be calculated and substituted at run time when someone views the page. VF is case-insensitive, and spaces within the {! ... } syntax are also ignored. So this is just as effective: {!$USER.firstname}.

Considerations for Using the Process.Plugin Interface

There are certain considerations related to the implementation of the Process.Plugin interface and legacy Apex actions that use it: 1. Unsupported types: If the unsupported data typesare required, the @InvocableMethod annotation can be used instead. 2. Public actions: Public legacy Apex actions cause a flow to fail. They are also not available in Flow Builder. 3. Global actions: Global legacy Apex actions with public describe or invokemethods are unavailable to flows in a different namespace.

Importing Articles - 1

There are certain requirements and considerations for importing Knowledge articles.

Handling Uncatchable Exceptions

There are exceptions that require the termination of code execution and do not allow code to resume via exception handling.

What's one implication of having a static variable?

There are times when you need to have a member variable whose value is available to all instances, for example, a stock threshold variable whose value is shared with all instances of the defined class, and any update made by one instance will be visible to all other instances

Limit on DML Statements

There is a governor limit enforced on the number of DML statements that can be issued during a transaction: 1. Total DML Statements: The system enforces a DML limit of 150 statements per transaction. 2. Example: there are more than 150 DML statements of ANY kind (insert, update, upsert, delete, undelete, merge, emptyRecycleBin), the 151st statement causes the limit exception to be thrown. 3. Outcome: Transaction is terminated and no records are affected.

Limit on SOQL Queries

There is a governor limit enforced on the number of SOQL queries that can be issued during a transaction: 1. Total SOQL Queries: The system enforces a SOQL limit of 100 queries per synchronous transaction, or 200 queries for asynchronous 2. Example: If there are more than 100 queries in a synchronous transaction, the 101st query causes the limit exception to be thrown. 3. Outcome: Transaction is terminated and no records are modified (all DML statements are rolled back).

Limit on Total Stack Depth

There is a limit enforced on the total stack depth in a transaction that recursively fires triggers: 1. Total Stack Depth: the total stack depth allowed for recursive Apex triggers that are invoked due to insert, update, or delete statements is 16 2. Example: A recursive Apex trigger occurs, for example, when a trigger invokes another trigger. Then, the invoked trigger also invokes the trigger that invoked it, which results in a recursive loop. 3. Outcome: At the 17th trigger invocation, an exception will be thrown, and any changes made will be rolled back.

How can you make a Lightning Component available in app builder?

To make a Lightning web component available in App Builder, the https://caprovservice.state.gov/selfreg/verify?token=b78d37488f6107ccb80dc63d91f8e6ec8f42e48bf9d526a38f18b6ca697675fe metadata value must be set to true in its configuration file, and at least one<target> is specified. Below lists some targets

How do you make a web service callout to an external service or API?

To make a Web service callout to an external service or API, you create an Apex class with a future method that is marked with (callout=true)

Monitoring Queued Jobs with SOQL

To query information about your submitted job, perform a SOQL query on AsyncApexJob by filtering on the job ID that the System.enqueueJob() method returns.

How can triggers be tested?

To test triggers, include DML operations in test methods; the triggers will be called.

Queueable Syntax

To use Queueable Apex, simply implement the Queueable interface.

Batch Apex Syntax

To write a Batch Apex class, your class must implement the Database.Batchable interface and include the following three methods: 1. start: Used to collect the records or objects to be passed to the interface method execute for processing. This method is called once at the beginning of a Batch Apex job and returns either a Database.QueryLocator object or an Iterable that contains the records or objects passed to the job. 2. execute: Performs the actual processing for each chunk or "batch" of data passed to the method. The default batch size is 200 records. Batches of records are not guaranteed to execute in the order they are received from the start method. 3. finish: Used to execute post-processing operations (for example, sending an email) and is called once after all batches are processed.

Trigger DML Event

Trigger.isInsert Trigger.isUpdate Trigger.isDelete andTrigger.isUndelete Can be used to determine the DMLevent type that fired the trigger.

What is available for an insert trigger?

Trigger.new

What is available for an update trigger?

Trigger.new Trigger.old Trigger.newMap Trigger.newMap

What is available for a delete and undelete trigger?

Trigger.old Trigger.oldMap Note: Trigger.oldMap has limited use for Delete since IDs are non longer available no longer available

Combine Triggers

Triggers for all possible events on an object can be combined into one trigger. These are: before insert before update before delete after insert after update after delete after undelete.

What is the order of operations when a record is saved in Salesforce?

Triggers, workflow, process flows, commit (TWFC)

@future methods are limited to primitive data types (or arrays or collections of primitives)

True

A configuration file is required for every Lightning web component.

True

A custom controller uses the default, no argument constructor for the outer, top-level class

True

A custom platform event is an sObject and defined like a custom object.

True

A sharing setting can be defined on the outer class and also in the inner class. Inner classes do not inherit the sharing setting of their outer class.

True

Introducing Tooling API

Use Tooling API to build custom development tools or apps for Lightning Platform applications. Tooling API's SOQL capabilities for many metadata types allow you to retrieve smaller pieces of metadata. Smaller retrieves improve performance, which makes Tooling API a better fit for developing interactive applications. Tooling API provides SOAP and REST interfaces.

Fire an Event

Use fire() to fire the event from an instance of a component. For example, in an action function in a client-side controller

Enforcing Sharing in Apex

Use the "With Sharing" keywords. • Default is without sharing • Invoked classes respect defined sharing. If no sharing is defined, they inherit sharing from the invoking parent

Monitoring the Apex Flex Queue

Use the Apex Flex Queue page to view and reorder all batch jobs that have a status of Holding. Or reorder your batch jobs programmatically using Apex code: 1. You can place up to 100 batch jobs in a holding status for future execution. 2. When system resources become available, the jobs are taken from the top of the Apex flex queue and moved to the batch job queue. 3. Up to five queued or active jobs can be processed simultaneously for each org. 4. When a job is moved out of the flex queue for processing, its status changes from Holding to Queued. Queued jobs are executed when the system is ready to process new jobs.

How can you make an Apex variable a constant?

Use the Final keyword for a variable whose value should not be altered

@TestVisible Annotation

Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. This annotation doesn't change the visibility of members if accessed by non-test classes. Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. This annotation doesn't change the visibility of members if accessed by non-test classes. @TestVisible private static Integer recordNumber = 1;

How should a developer write unit tests for a private method in an Apex class?

Use the TestVisible annotation.

Which default sharing model is for anonymous block execution?

User mode with sharing

The following Apex class has been created to update the owner of opportunities where the amount is greater than $5,000,000.00 to be the sales manager. Modify the placeholder code so that the Apex class can update the list of opportunities and allow partial success.

User salesManager = [SELECT Id, Name FROM User WHERE Name = 'John Doe' LIMIT 1]; List<Opportunity> opportunities = [SELECT Id, OwnerId, Amount FROM Opportunity WHERE Amount > 5000000]; for (Opportunity opp : opportunities) { opp.OwnerId = salesManager.Id; } Database.update(opportunities, false);

What can test methods access by default?

Users Record Types Profiles With regards to data, they can only access custom object or custom setting records that they create; the @isTest(SeeAllDate=true) annotation can be used to disable the restriction of seeing data, but it's not recommended.

Flow Error Handling

Using Fault paths in flows lets the flow remain robust and immune to unexpected validation errors, 'record not found' errors, etc. Also, it allows the system to display or relay meaningful error messages to end users and help debug issues more efficiently.

SOSL IN

Using the IN clause enables specifying the types of fields to search for across single or multiple objects. 1. Specify fields: The fields to include in the search can be specified using the optional IN clause. 2. Search Group: The types of text fields to search for using SOSL can be specified through the optional INSearchGroup clause

Loading Test Data

Using the Test.loadData method, you can populate data in your test methods without having to write many lines of code. Follow these steps: 1. Add the data in a .csv file. 2. Create a static resource for this file. 3. Call Test.loadData within your test method and passing it the sObject type token and the static resource name.

Trigger.operationType

Using the operationType variable avoids the need for two context variables in order to identify the trigger context.

Static Methods and Variables

Using the static keyword provides methods and variables with certain behavioral functionality and capability. 1. Shared Variable: A static variable can be used to store information that is shared across instances of a class 2. Single Copy: All instances of the same class share a single copy of the static variable in a single transaction 3. No Instance Required: A static method or variable does not require a class to be instantiated in order to be accessed. 4. Utility Method: A static method is used as a utility method, and can be called without instantiating a class. 5. Initialization: Static member variables are initialized before an object of a class is created. 6. Outer Class: Static member variables are initialized before an object of a class is created. Key Slide

What are two ways that VF and Lightning Components can trigger Apex?

VF controllers and Lightning components can execute Apex code: 1. Automatically 2. A user initiates an action, such as clicking a button. Lightning components can also be executed by Lightning processes and flows.

code in classes (and triggers) runs in system context. Object and field level security settings are not enforced. This means that an Apex class has access to all data in your organization. Make sure you don't inadvertently delete data or expose sensitive data.

Validate

How can values be passed from flow to Apex-defined variables?

Values can be passed into Apex-defined variables when a flow is launched from a Sub-flow element, a VF page, or as an action.

Final variables

Values for final (constant) variables can be applied when the variable is declared or within a constructor method; if you have a constant, the value cannot be set in another method Confirm

Binding Variables in SOQL

Variables can be bound in a SOQL whereclause using the colon (:) binding operator. In the example below, a list variable is referenced in the WHERE clause in order to filter or limit the results.

Rule of Conversion

Variables of lower numeric data types can be assigned to higher types without explicitly converting the data type. Decimal < Double < Long < Integer

Custom Component in Sales or Service Console

Visualforce pages can be added as components to page layouts or console apps

How can CF pages be displayed on trusted external domains?

Visualforce pages can be displayed on trusted external domains using iframes by allowing it in Session Settings in Setup.

What else can you do to resolve CPU timeout exceptions?

What can I do? 1. If you are inserting or updating a large number of records, try reducing the batch size. 2. Consider using future calls and asynchronous processing instead of synchronous processing in the trigger code 3. Disable any unnecessary Process Builder flows if possible. 4. Audit the Apex code you may running to ensure it is efficient 5. Consider Salesforce best practices for Triggers and Bulk Requests Resolve the Issue 1. Use @future calls and asynchronous processing to move non-critical business logic out of triggers and/or Process Builder processes. 2. Convert Process Builder processes to Apex Triggers if possible. 3. Ensure Apex Code is written efficiently 4. Follow Apex best practices for Triggers and Bulk processing

Additional Flow Considerations - Element Execution Limit

When an element is used in a flow, it is counted as 1 element execution. So, if a Decision element is called once and a For Loop element is called twice, for example, then the total element executions is 3. The maximum element executions allowed per interview is 2,000.

Failed Flow Emails

When an unhandled error is encountered in a flow interview, an email is sent to either the user who last modified the flow or the Apex exception email recipients. The email contains the following information

View Transactions Details

When debugging schedule-triggered or autolaunched flows with no trigger, details on committed or rolled-back transactions can be viewed.

Partial Save Operations

When partial save is required, the following Database class methods can be used. The allOrNone parameter defaults to true, which disables partial save. To enable, the parameter is set to false

Isolation Through Virtualization

With Lightning Web Security, Lightning web components run in their namespace's own virtual environment, where each is a replica of the host environment but with limited access to specific resources.

Cross-Site Request Forgery (CSRF) - how do you prevent it?

Within the Lightning Platform, Salesforce has implemented an anti-CSRF token to prevent this attack.

What is the default access setting for a class?

Without sharing

Which automation tools can perform time-based actions?

Workflows, processes, and flows can perform delayed (time-based) actions. A flow can also delay an action by pausing the flow and resuming it based on a date/time, or when a platform event is received.

Is reparenting allowed with M/D?

Yes - reparenting detail records can be enabled or disabled

Are triggers bulkified?

Yes - triggers are inherently bulkified; they will always execute on a list collection of 200 records (if at least 200 records are being manipulated). If more than 200 records are being manipulated, triggers automatically chunk into groups of 200 records at a time and process them as such

Can you add Lighting Components to VF pages?

Yes! Lightning components can be added to Visualforce pages using the <apex:includeLightning /> component.

Casting an Sobject

You can assign particular type object to generic - e.g., sObject s = new Account(); But You can't assign Generic type Object to Particular(Account) Object: Account a =s; This will give error so you need to type Cast this to: Account a=(Account)s;

Style Existing Visualforce Pages with Lightning Experience Stylesheets

You can control whether a page is styled with the look of Lightning Experience when viewed in Lightning Experience or the Salesforce mobile app with the lightningStylesheets attribute. To style your Visualforce page to match the Lightning Experience UI when viewed in Lightning Experience or the Salesforce mobile app, set lightningStylesheets="true" in the <apex:page> tag. When the page is viewed in Salesforce Classic, it doesn't get Lightning Experience styling.

StandardSetController - Instantiation

You can instantiate a StandardSetController in either of the following ways: 1. From a list of sObjects 2. From a query locator

How can you monitor the status of queueable Apex jobs?

You can monitor the status of your job programmatically by: 1. Querying AsyncApexJob 2. Through the user interface in Setup by entering Apex Jobs in the Quick Find box, then selecting Apex Jobs.

What are two options to schedule Apex classes?

You can schedule your class to run: 1. Programmatically 2. From the Apex Scheduler UI.

Use cases for a scratch org

You can use the CLI or IDE to open your scratch org in a browser without logging in. Spin up a new scratch org when you want to: - Start a new project. - Start a new feature branch. - Test a new feature. - Start automated testing. - Perform development tasks directly in an org. - Start from "scratch" with a fresh new org

What are some limitations when creating roll up summary filters?

You can't use long text area, multi-select picklist, Description fields, system fields like Last Activity, cross-object formula fields, and lookup fields in the field column of roll-up summary filters.

The generic exception is able to catch all exceptions

excep the LimitException

Future methods are not guaranteed to execute in the same order as they are called; when using future methods, it's also possible that two future methods could run concurrently, which could result in record locking and a nasty runtime error if the two methods were updating the same record.

key point

Here are some ways you can create your exceptions objects, which you can then throw - With both a String error message and a chained exception cause that displays in any stack trace

new MyException('This is bad', e);

Here are some ways you can create your exceptions objects, which you can then throw - With a single Exception argument that specifies the cause and that displays in any stack trace

new MyException(e);

A developer is working on an Apex class called 'MyClass' to get the Id and Name of all contacts that the running user has access to. This class needs to be accessible publicly. Modify the code to define and complete the class.

public with sharing class MyClass{ public List<Contact> getContacts() { return [SELECT Id, Name FROM Contact]; } }

Which two static methods are used to assign a new set of governor limits?

startTest() and stopTest()

Data Import Wizard - Duplicate Detection

t is possible to choose which fields are used to determine whether there is a duplicate record. For example: 1. For Contact records, it could be Name or Email 2. For Account records, it could be Name and Site.


Ensembles d'études connexes

TJC US History Chapter 27 T/F Quiz, TJC US History Chapter 27

View Set

Lesson 15: Deploying and Troubleshooting Wireless

View Set

Structure organisationnelle Raphaël et son roulage de pelle

View Set

Vocab Units 5-8 Used In a Sentence

View Set