• #29691
    Salesforce | Sanjana Sanjana #13
    Forcetalks

    What are context variables in Salesforce Triggers?

    What are context variables in Salesforce Triggers?

    Tagged: , , , ,

    #30172
    Forcetalks

    Hii Sanjana,

    Context variables, as the name implies, refers to the fact that what the context of the trigger fire is . These are basically the implicit variables that that allow developers to access run time context. Some of the examples of context variables are isInsert, isUpdate, isDelete etc.

    #34070
    Salesforce | Parul Parul #1
    Forcetalks

    All triggers define implicit variables that allow developers to access run-time context. These variables are contained in the System.

     

    1) isExecuting Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or anexecuteanonymous() API call.
    2) isInsert Returns true if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or theAPI.
    3) isUpdate Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or theAPI.
    4) isDelete Returns true if this trigger was fired due to a delete operation, from the Salesforce user interface, Apex, or theAPI.
    5) isBefore Returns true if this trigger was fired before any record was saved.
    6) isAfter Returns true if this trigger was fired after all records were saved.
    7) 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.)
    8) 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.
    9) 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.
    10) 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.
    11) 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.
    12) size The total number of records in a trigger invocation, both old and new.

     

    Thanks.

    #34129
    Salesforce | shariq shariq #2
    Forcetalks

    Hi,

    All triggers define implicit variables that allow developers to access run-time context. These variables are contained in the System.Trigger class.

    Variable

    isExecuting
    Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, 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.This sObject list is only available in insert, update, and undelete triggers, and the records can only be modified in before triggers.
    newMap
    A map of IDs to the new versions of the sObject records.This map is only available in before update, after insert, after update, and after undeletetriggers.
    old
    Returns a list of the old versions of the sObject records.This sObject list is only available in update and delete triggers.
    oldMap
    A map of IDs to the old versions of the sObject records.This map is only available in update and delete triggers.
    size
    The total number of records in a trigger invocation, both old and new.

    Hope this helps!

Viewing 4 posts - 1 through 4 (of 4 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?