Activity Forums Salesforce® Discussions What are the available Trigger contest variables in salesforce?

  • Suraj

    Member
    May 12, 2017 at 1:50 pm

    Hi Saurabh,

    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.
  • Louis

    Member
    June 2, 2017 at 11:06 am

    Hi Saurabh,

    Context variable return true or false.

    1.       isBefore

    2.       IsAfter

    3.       IsInsertIsUpdate

    4.       IsUndelete

    5.       Old:-:- return old value of record in list

    6.       oldMap :- return old value of record in key value pairr

    7.       new:-return new  value of record in list

    8.       newMap :-return new  value of record in key value pair

    9.       return new  value of record in list

    10.   isExecuting-when trigger is fired from only from apex class

    11.   size :- total no of record in trigger invocation.

    thesevariables type is Boolean and return true or false. When a trigger is fired on an object then these variable return true as per the event of trigger.

    Example:-

    Trigger abc on account(isbefore,isafter,isInsert,isUpdate)

    If(isbefore()){

    If(isInsert()){

    //perform task

    }

    }

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos