Advanced Developer Certification, DEV 501 Quick Points Part-II
- The apex array is
dynamic, but java array is static
- If field history is
enabled for an object the data which is getting stored in field history will be
anyType.
- Enum data type methods:ordinal():- returns the
position of item in the listName():- returns the
name of the enum item as a stringvalues():- static method
that returns the list of values
- SaveResult object has 3
methods.Id getId()List<Database.Error> getErrors()Boolean isSuccess()
- If the DML operation
contains only one record we can use saveResult instead of
list<SaveResult>
- External field contains
externalid attribute.
- Execution of
setsavePoint(), rollback() counts against the total number of DML statements.
- You cannot add isdeleted
flag into page layout.
- Trigger by definition
will not receive more than 200 records in trigger.new
- Each DML statement can
only operate on one type of SObject at a time.
- Merging limited to 3
records at a time and its limited to leads, accounts, contacts.
- If there are uncaught
exceptions while performing DML operations then system will roll back.
SavePoint sp = database.setSavepoint();Database.rollback(sp); - Approval Process:-ProcessRequest ,ProcessSubmitRequest,
ProcessWorkItemRequest.ProcessRequest is a parent class for both
ProcessSubmitRequest and ProcessWorkItemRequest.
- Approval process should
be defined for approval process through apex.
- Webservice ,
remoteaction methods cannot overloaded,
- Apex cannot access file
system or create temporary files in salesforce.
- SObject clone method has
4 parameters1.preserve id2.deepclone - All fields on the SObject are
duplicated in memory, including relationship fields3.Readonly timestamps - Determines whether the
read-only timestamp fields are preserved or cleared in the duplicate.4.preserve_autonumber - Determines whether
auto number fields of the original object are preserved or cleared in the
duplicate.
- SObject toString method
returns the object values into string.
- Apex sharing can be set
only for custom objects, but standard objects can be shared with apex. The
sharing reason for standard objects will always be manual.
- If history tracking is
enabled then Object__history object will be created automatically for that
custom object.
- full,read,read/write,
write sharing are there for an object. Full is granted only for record owners.
- Interfaces are
implicitly virtual, so no need to define virtual keyword for interfaces.
- Organization wide
sharing changes will remove the redundant sharing records.
- Inner class behave like
static java inner class.
- Virtual keyword used to
extends or override the class and methods.
- Abstract keyword used if
the class contains incomplete implementations.
- Global classes are used
for Email service,webservice and AppExchange products.
- Schema.DescribeFieldResult
F = Account.AccountNumber.getDescribe();Schema.DescribeFieldResult
F = Schema.SObjectType.Account.fields.Name;Map<String,
Schema.SObjectField> M = Schema.SObjectType.Account.fields.getMap();Schema.DescribeSobjectResult[]
results = Schema.describeSObjects(types);
//It can have 100 objects as argument to it. - Accessing all SObjects:-Map<String,
Schema.SObjectType> gd = Schema.getGlobalDescribe();
- In dynamic soql you can
use bind variable in query string, but you cannot use SObject field as bind
variable in dynamic soql.
- DML operation always
require list of sobjects, list<object> will not support in DML.
- Salesforce automatically
recalculates sharing for all records on an object when its organization-wide
sharing default access level changes. The
recalculation adds Force.com managed sharing when appropriate. In addition, all
types of sharing are removed if the access they grant is
considered redundant.
- Apex sharing reasons and
Apex managed sharing recalculation are only available for custom objects.
- An anonymous block is
Apex code that does not get stored in the metadata, but that can be compiled
and executed using one of the following:• Developer Console• Force.com IDE• The executeAnonymous
SOAP API call:Note the following about
the content of an anonymous block (for executeAnonymous, the code String):• Can include
user-defined methods and exceptions.• User-defined methods
cannot include the keyword static.• You do not have to
manually commit any database changes.• 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.• 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.• Do not have a scope
other than local. For example, though it is legal to use the global access
modifier, it has no meaning. The scope of the method
is limited to the anonymous block.• When you define a
class or interface (a custom type) in an anonymous block, the class or
interface is considered virtual by default when the
anonymous block executes. This is true even if your custom type wasn’t defined
with the virtual modifier. Save your
class or interface in Salesforce to avoid this from happening. Note that
classes and interfaces defined in an anonymous block aren't saved in your organization.
The return result for anonymous blocks includes:• Status information for the compile and execute phases of the call, including any errors that occur• The debug log content, including the output of any calls to the System.debug method• The Apex stack trace of any uncaught code execution exceptions, including the class, method, and line number for each call stack element. - Trigger.new is used only
by insert and update triggers.
- You can only use the
webService keyword in a trigger when it is in a method defined as asynchronous;
that is, when the method is
defined with the @future keyword.
- The code block of a
trigger cannot contain the static keyword. Triggers can only contain keywords
applicable to an inner class.
- If any record that fires
a trigger includes an invalid field value (for example, a formula that divides
by zero), that value is set to
null in the new, newMap, old, and oldMap trigger context variables.
- Be aware of the
following considerations for trigger context variables:• trigger.new and
trigger.old cannot be used in Apex DML operations.• You can use an object
to change its own field values using trigger.new, but only in before triggers.
In all after triggers, trigger.new is not saved, so a runtime exception is
thrown.• trigger.old is always
read-only.• You cannot delete
trigger.new.
- In before delete trigger
you can update field values of object using DML statements, not using
trigger.new.
- In after undelete you
can update the field values using DML statements.
- You cannot use
Trigger.new to update field values in any after triggers.
- You can update the
fields on object using trigger.new in before trigger if there are new version
of sobject being created in trigger.
- The after undelete
trigger events only run on top-level objects.
- The getContent and
getContentAsPDF PageReference methods aren't allowed in triggers.
- Methods with the future
annotation have the following limits:• No more than 10 method
calls per Apex invocation• The maximum number of
future method invocations per a 24-hour period is 250,000 or the number of user
licenses in your organization
multiplied by 200, whichever is greater.
- You can only have 100
scheduled Apex jobs at one time.
- To schedule an Apex
class to run at regular intervals, first write an Apex class that implements
the Salesforce-provided interface
- Schedulable interface.The Schedulable
interface contains one method that must be implemented, execute.global void
execute(SchedulableContext sc){}The implemented method
must be declared as global or public.
- Cron trigger schedule
string syntax:Seconds Minutes Hours
Day_of_month Month Day_of_week optional_year
- You can't use the
getContent and getContentAsPDF PageReference methods in scheduled Apex.
- Scheduling example:scheduledMerge m = new
scheduledMerge();String sch = '20 30 8 10
2 ?';String jobID =
system.schedule('Merge Job', sch, m);batchable b = new
batchable();database.executebatch(b);
- both of the above
method needs to implement schedulable interface.
- An easier way to
schedule a batch job is to call the System.scheduleBatch method without having
to implement the Schedulable interface.System.scheduleBatch (reassign,
'job example',
- To obtain the total
count of all Apex scheduled jobs, excluding all other scheduled job types,
perform the following query.
- Note the value '7' is
specified for the job type, which corresponds to the scheduled Apex job type.SELECT COUNT() FROM
CronTrigger WHERE CronJobDetail.JobType = '7'
- 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.
- You can only have five
queued or active batch jobs at one time
- To use a callout in
batch Apex, you must specify Database.AllowsCallouts in the class definition.
For example:global class SearchAndReplace implements Database.Batchable<sObject>,Database.AllowsCallouts{} - A maximum of 50 million
records can be returned in the Database.QueryLocator object.
- Each batch Apex invocation creates an AsyncApexJob record. Use the ID of this record to construct a SOQL query to retrieve the job’s status, number of errors, progress, and submitter.
Comments
Post a Comment