Salesforce certified Advanced Developer (DEV 501) notes

12:08 PM

I took down some notes while preparing for the DEV 501 objective exam (first level). Though it might not be that the questions are based out of this notes, i am sure that you will find these useful.

Comparison (triple =)

x === y, check reference. Check's whether the reference between the objects x and y is the same.


Collections in apex:

list - ordered, non unique
set - unordered, unique
map - unordered, key value pair

Check this link for a detailed description. - Click here

Variable types:

static - lifetime is throughout the entire execution context

final - value can be set only once (public static final Integer example = 1)

Query clauses:


ALL ROWS - returns all rows including those in the recycle bin and archived activities
(Ex: System.assertEquals(2, [SELECT COUNT() FROM Contact WHERE AccountId = a.Id ALL ROWS]);)

FOR UPDATE: locks the record for update from other means while the execution is happening.
(Ex:  Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE]; )

 Salesforce Query Language:

SOQL - returns a list of sObjects.
SOSL - returns a list of list of sObjects. This is because SOSL queries can query multiple objects.

DYNAMIC BINDING:
Treats the characters after ':' as executable Apex Code.

EXTERNAL ID: NOT unique by default

Webservice methods cannot be overloaded.

Case, switch statements not available in apex as of now. Use nested, IF- ELSE to accomplish this.

Three types of FOR loops:

1) for (integer i=0; i<100 i="" p="">
2) for (Integer i : List)

3) for (Account a: [Select Id from Account where Name != 'Edwin'])
    for (List accts : [SELECT id, name FROM account
                                                                               WHERE name LIKE 'Acme']) - Querymore mode


Apex Manual Sharing:
Row Cause: Can create custom row cause from the 'Apex Sharing Reasons' related list on the custom object. Ex: Schema.Object__Share.RowCause.Rowcausename__c

Access: Read, Edit, Full (this is only for owner and cannot be set for other users)

Field: IsDeleted = TRUE, indicates records in the recycle bin


Different database operations:
INSERT UPSERT UPDATE DELETE MERGE UNDELETE

database.dmloptions - Ex: truncation (text fields exceeding max limit- truncate or throw error)

database.setsavepoint()
datase.rollback(savepointname)

You can have a maximum of upto 5 savepoints.
No explicit COMMIT statement, commit happens implicitly at the end of the transaction.

Different types of trigger events:

before insert
before update
after insert
after update
before delete
after delete
after undelete

if you have 4 different triggers on say the 'before insert' event, there is no guarantee on the execution order of the triggers

Merge event - delete on losing record, update on winning record


Cascade DELETE - if a master record is deleted the trigger fires on the master record, however even though the detail records are deleted the trigger does not fire on the detail records.

String comparison in apex: uppercase A is different from lowercase a

Exception Handling:

try {throw} catch (){} finally{}

public class MyException extends Exception{}

//try, throw and catch
     try {
         Integer i;
         //Your code here
         if ( i < 5 ) throw new MyException();
    } catch ( MyException e ) {
         //Your MyException handling code here
    }
    finally { system.debug('executes no matter what');}


############### Apex Code Developer's Guide##########################
Custom Labels: Accessed using the notation System.Label.Label_Name

If You have Person Accounts enabled and you insert an Account using (name='xxx') a Business Account is created. If you insert a account using (Lastname ='yyy') a person account is created.

Relationship tip:
When being read as a value, if c.Account is null, then c.Account.Name evaluates to null,but does not yield a NullPointerException.
When being modified, if c.Account is null, modifying c.Account.Name does yield a NULL pointer exception.

A LIST can contain unto four levels of nested lists.

Use the Comparable interface to implement a custom sort for Lists.

2 comments

  1. Nice post. Wish you good luck with your exam.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

AD