Trigger-salesfroce
Trigger:
Trigger
is also same as stored procedures and if whenever DML operation performed
against s-object or view.
There
are two types supported by salesforce
·
Object-level
·
record-level
Object-level:
In object-level triggers body of the trigger executed
only ones for
Object.
Record-level:
In
record-level trigger body executed for each row (record) based on DMLStatements
(input/output)
Qualifiers:
Be entitled to a benefit or privilege by fulfilling a necessary
condition
·
new
·
old
Level
trigger
New-
Insert
Update
Old-
Update
Delete
Trigger actions:
·
before(old)
·
after(future)
Trigger are using in the collections
are receives the data
·
List
·
Set
·
Map
·
For-each
·
For
Trigger
Definition
trigger
validateTimecard on Timecard__c(before insert, before update) {
code block
}
Q: what are the trigger events? Next post
Trigger-salesfroce-1
Trigger
Context Variables: 11
Triggers define implicit variables that allow
developers to access runtime context. These variables are contained in the System. Trigger
class:
Note: is-Boolean (true/false)
Variable Usage:
isExecuting:
Returns true if the current context for the
Apex code is a trigger, not a Visualforce page, a Webservice, or an
executeanonymous() API call.
isInsert
Returns true if this
trigger was fired due to an insert operation, from the Salesforce user
interface, Apex, or the
API.
isUpdate
Returns true if this trigger was fired due to
an update operation, from the Salesforce user interface, Apex, or the API.
isDelete
Returns true if this
trigger was fired due to a delete operation, from the Salesforce user
interface, Apex, or the
API.
isBefore
Returns true if this
trigger was fired before any record was saved.
isAfter
Returns true if this trigger was fired after
all records were saved.
isUndelete
Returns true if this trigger was fired after a
record is recovered from the Recycle Bin (that is, after an undelete operation
from the Salesforce user interface, Apex, or the API.)
new
Returns a list of the new
versions of the sObject records.
Note: that this sObject
list is only available in insert and update triggers,
and the records
can only be modified in
before triggers.
newMap
A map of IDs to the new
versions of the sObject records.Note that this map is only available in before update, after insert, and
after Update triggers.
Old
Returns a list of the old versions of the
sObject records.
Note :that this sObject
list is only available in update and delete triggers.
oldMap
A map of IDs to the old
versions of the sObject records.
Note that this map is only
available in update and delete triggers.
size
The total number of
records in a trigger invocation, both old and new.
No comments:
Post a Comment