Salesforce Platform Developer I
Order of Execution
1) Loads the original record from the database or initializes the record for an upsert statement. Loads the new record field values from the request and overwrites the old values. If the request came from a standard UI edit page, Salesforce runs system validation to check the record for: Compliance with layout-specific rules Required values at the layout level and field-definition level Valid field formats Maximum field length When the request comes from other sources, such as an Apex application or a SOAP API call, Salesforce validates only the foreign keys. Before executing a trigger, Salesforce verifies that any custom foreign keys do not refer to the object itself. Salesforce runs user-defined validation rules if multiline items were created, such as quote line items and opportunity line items. Executes all before triggers. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules. Executes duplicate rules. If the duplicate rule identifies the record as a duplicate and uses the block action, the record is not saved and no further steps, such as after triggers and workflow rules, are taken. Saves the record to the database, but doesn't commit yet. Executes all after triggers. Executes assignment rules. Executes auto-response rules. Executes workflow rules. If there are workflow field updates, updates the record again. If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules, duplicate rules, and escalation rules are not run again.
Benefits of Queueable Apex
1. *Non-primitive types* - Classes can accept parameter variables of non-primitive data types, such as sObjects or custom Apex types. 2. *Monitoring* - When you submit your job, a jobId is returned that you can use to identify the job and monitor its progress. 3. *Chaining jobs* - You can chain one job to another job by starting a second job from a running job. Chaining jobs is useful for sequential processing.
Typical development lifecycle:
1. Create sandbox 2. Develop in sandbox 3. Test in sandbox 4. update sandbox from production 5. Deploy to production
Apex provides built-in support for common Lightning Platform idioms, including
1. Data munipulation
Methods of Invoking Apex
1. Database Trigger 2. Anonymous Apex 3. Asynchronous Apex 4. Web Services 5. Email Services 6. Visualforce or Lightning pages
The three types of for loops are:
1. Iteration using a variable 2. Iteration over a list 3. Iteration over a query
System.Debug Log Levels
1. NONE 2. ERROR 3. WARN 4. INFO 5. DEBUG 6. FINE 7. FINER 8. FINEST
Stages of the AppExchange Product Lifecycle
1. Plan 2. Build and Test 3. Distribute 4. Market 5. Sell 6. Support
When should you use asynchronous apex
1. Processing a very large number of records. 2. Making callouts to external web services. 3. Creating a better and faster user experience
What are 3 limitations of Batchable interface
1. Troubleshooting can be troublesome 2. Jobs are queued and subject to server availability, which can sometimes take longer than anticipated. 3. Limits
How do you use batch apex
1. Use implements database.batchable<sObject> 2. Define start() method 3. Define end() method 4. Define finish() method
What are 3 limitations of future callouts
1. You can't track execution because no Apex job ID is returned. 2. Parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. Future methods can't take objects as arguments. 3. You can't chain future methods and have one call another.
Types of Triggers
1. before insert 2. before update 3. before delete 4. after insert 5. after update 6. after delete 7. after undelete
Maximum number of push notification method calls allowed per Apex transaction
10
Total number of sendEmail methods allowed
10
Maximum execution time for each Apex transaction
10 minutes
Total number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin
10,000
Total number of records retrieved by Database.getQueryLocator
10,000
Total number of callouts (HTTP requests or Web services calls) in a transaction
100
Maximum cumulative timeout for all callouts (HTTP requests or Web services calls) in a transaction
120 seconds
Total number of DML statements issued
150
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements
16
Maximum number of push notifications that can be sent in each push notification method call
2,000
Total number of records retrieved by a single SOSL query
2,000
Total number of SOSL queries issued
20
Apex triggers can receive up to _______ objects at once
200
Size limit for each debug log
2mb - you won't see anything passed the limit
Number of page layouts when creating a new object?
4 - two page layouts, and two single record views
Number of records dataloader can import
5,000,000
Maximum number of Apex jobs added to the queue with System.enqueueJob
50
Maximum number of methods with the future annotation allowed per Apex invocation
50
Number of records import wizard can import
50,000
Total number of records retrieved by SOQL queries
50,000
Total storage allowed for debug logs
50mb - oldest logs are overwritten
Which code block returns the ListView of an Account object using the following debug statement? system.debug(controller.getListViewOptions() ); A. ApexPages.StandardSetController controller = new ApexPages.StandardSetController( Database.getQueryLocator( 'SELECT Id FROM Account LIMIT 1')); B. ApexPages.StandardController controller = new ApexPages.StandardController( [SELECT Id FROM Account LIMIT 1]); C. ApexPages.StandardController controller = new ApexPages.StandardController( Database.getQueryLocator( 'SELECT Id FROM Account LIMIT 1')); D. ApexPages.StandardController controller = new ApexPages.StandardController( [SELECT Id FROM Account LIMIT 1]);
A. ApexPages.StandardSetController controller = new ApexPages.StandardSetController( Database.getQueryLocator( 'SELECT Id FROM Account LIMIT 1'));
Which statement would a developer use when creating test data for products and pricebooks? A. Id pricebookId = Test.getStandardPricebookId(); B. Pricebook pb = new Pricebook(); C. IsTest(SeeAllData = false); D. List objList = Test.loadData(Account.sObjectType, 'myResource');
A. Id pricebookId = Test.getStandardPricebookId();
Declares a class that contains abstract methods that only have their signature and no body defined. Can also define methods.
Abstract public *ABSTRACT* class Foo { protected void method1() { /*... */ } *ABSTRACT* Integer abstractMethod(); }
Syntax for writing a class
Access Modifier (Public/Private/Global) Virtual/abstract/With Sharing/ Without Sharing Class ClassName [Implements InterfaceNameList] [Extends ClassName] { //Body of the class } public with sharing class HelloWorld { public void printMessage() { String msg = 'Hello World'; System.debug(msg); } }
How to convert a method to asynchronous
Add the @future(callout=true) before the method
A developer wrote a workflow email alert on case creation so that an email is sent to the case owner manager when a case is created. When will the email be sent?
After committing to the database
Code snippets executed on the fly in Dev Console & other tools.
Anonymous Apex
In a single record, a user selects multiple values from a multi-select picklist. How are the selected values represented in Apex?
As a String with each value separated by a semicolon
Which trigger event allows a developer to update fields in the Trigger.new list without using an additional DML statement?Choose 2 answers
Before insert and Before update
Identifies a block of code that can handle a particular type of exception
Catch try { // Your code here } *CATCH* (ListException e) { // List Exception handling code here }
Cross object formulas always work from ________ to ________?
Child to parent - formula field is ALWAYS created on the child object and reference fields from the parents
A facility for changing the state of the model
Controller - Apex code
Invoked for a specific event on a custom or standard object.
Database Trigger
Allows you to save mappings
Dataloader
Allows you to schedule imports
Dataloader
The primary source of debug information on the Force.com platform is the
Debug Log
Where would a developer build a managed package?
Developer edition
Code that is set up to process inbound email.
Email Services
The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page
Enforcement of layout-specific rules.
Defines a class or interface that extends another class or interface
Extends public class MyException *EXTENDS* Exception {} try { Integer i; if (i < 5) throw new MyException(); } catch (MyException e) { // Your MyException handling code }
Identifies a block of code that is guaranteed to execute
Finally try { // Your code here } catch (ListException e) { // List Exception handling code } *finally* { // will execute with or without // exception }
Defines a class, method, or variable that can be used by any Apex that has access to the class, not just the Apex in the same application.
Golbal *global* class myClass { webService static void makeContact(String lastName) { // do some work }
Allows data to be imported without firing triggers
Import wizard - can choose to not run triggers
When to use future methods
In situations where you need to make a callout to a web service or want to offload simple processing to an asynchronous task, creating a future method could be the way to go.
What happens when declare a method or variable as static?
It's initialized only once when a class is loaded. Static variables aren't transmitted as part of the view state for a Visualforce page.
What Is a Lightning Component?
Lightning components are building blocks for apps. They're self-contained and reusable, and they let Salesforce customers design solutions to business problems with an intuitive, drag-and-drop interface called the Lightning App Builder.
AW Computing populates the industry field on customer account records. The sale steam wants the industry information displayed on related opportunity records and updated when the value is updated on the account record. How can a developer meet this requirement?
Look up
What type of relationship exists between Contact and Account?
Lookup
An entity representing data or activity. The database
Model
Which type of information is provided by the Checkpoints tab in the Developer Console?
Namespace, Class, Line, Time
Asynchronous Apex
Occurs when executing a future or queueable Apex, running a batch job, or scheduling Apex to run at a specified interval.
If the record was updated with workflow field updates, fires before update triggers and after update triggers how many times
Once
Automation that can call apex code
Process Builder Visual workflow
What is a checkpoint
Reveal detailed execution info about a line of code. they do not stop execution
AW computing uses the certification held object to track if a service technician has passed a certification. There is a master detail relationship between the contact object (Master) and the certification held object (Detail). The professional services team wants to track the total number of certifications held by each service technician contact. How can a developer meet this requirement?
Roll-up summary field on the master object
A ______ field can reference fields on the child objects
Roll-up summary if there is a master-detail relation
All . @AuraEnabled controller methods must have what type of access modifier?
Static
Total number of SOQL queries issued
Synchronous: *100* Asynchronous: *200*
Maximum CPU time on the Salesforce servers
Synchronous: 10,000 MS Asynchronous: 60,000 MS
Total heap size
Synchronous: 6MB Asynchronous: 12MB
Format to include level in system.debug()
System.debug(LoggingLevel.INFO, 'My Info Debug Message'); System.debug(LoggingLevel.FINE, 'My Fine Debug Message');
How do you invoke Queueable Apex
System.enqueueJob(new MyQueueableClass())
Data types available in formula fields
The data type of a formula determines the type of data you expect returned from your formula. Checkbox Currency Date Date/Time Number Percent Text Time
What happens if a method is defined as with sharing and it is called from a class defined as without sharing
The method executes in user context respecting the sharing rules.
What happens during a trigger execution if the duplicate rule identifies the record as a duplicate and uses the block action
The record is not saved and no further steps, such as after triggers and workflow rules, are taken.
What Is Execution Context?
This context represents the time between when the code is executed and when it ends.
If more complex logic is needed than a roll-up summary field can provide a possible solution could be a ______?
Trigger
True/False - The sharing setting of the class where the method is defined is applied, not of the class where the method is called.
True
True/False Process Builder can update fields on the child objects
True
True/False Workflow rules can update fields on the record itself or it's related parents for an update. Never children
True
True/False variables are initialized to null by default
True
True/False By default, Apex executes in system context
True Object permissions, field-level security, and sharing rules aren't applied for the current user. You can use the with sharing keyword to specify that the sharing rules for the current user be taken into account for a class
Visualization of the state of the model
View - Visualforce pages, page layouts
Automation that can delete record (directly w/o apex)
Visual workflow only
Can execute Apex code automatically or when a user initiates an action, such as clicking a button.
Visualforce controllers and Lightning components Lightning components can also be executed by Lightning processes and flows.
Code that is exposed via SOAP or REST
Web services.
When are formula fields calculated
When the page is loaded
Automation that supports time based actions
Workflow Process Builder Visual Workflow
Why would you use batch or scheduled Apex
You need to process a large number of records.
Allows you to export or delete data
dataloader
Defines constants
final public class myCls { static *final* Integer intConstant; }
Declares a class or interface that implements an interface
implements global class CreateTaskEmailExample *IMPLEMENTS* Messaging. InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging. inboundEmail email, Messaging.InboundEnvelope env){ // do some work, return value; } }
The basic syntax for a trigger
trigger TriggerName on ObjectName (trigger_events) { // code_block }