5. isInsert: Returns true if the trigger was fired due to an insert operation.

6. isUpdate: Returns true if the trigger was fired due to an update operation.

7. isDelete: Returns true if the trigger was fired due to a delete operation.

8. isUndelete: Returns true if the trigger is fired after a record is recovered from recycle bin.

9. isBefore: Returns true if the trigger was fired before any record was saved.

10. isAfter: Returns true if the trigger was fired after all records were saved.

11. Size: Returns the total number of records in a trigger invocation, both old and new.

trigger ApexTrigger on Contact (before insert, before update, before delete, after insert, after update, after delete) {

    // 5) isInsert

    // 6) isUpdate

    // 7) isDelete

    // 8) isUndelete

    // 9) isBefore

    //10) isAfter

    //11) Size

    if(trigger.isBefore)

    {

        if(trigger.isInsert)

        {

            System.debug(‘I am before Insert’);

        } else if(trigger.isUpdate)

        {

            System.debug(‘I am before Update’);

        } else if(trigger.isDelete)

        {

            System.debug(‘I am before Delete’);

        } 

    } else if(trigger.isAfter)

    {

        if(trigger.isInsert)

        {

            System.debug(‘I am after Insert’);

        } else if(trigger.isUpdate)

        {

            System.debug(‘I am after Update’);

        } else if(trigger.isDelete)

        {

            System.debug(‘I am after Delete’);

        } else if(trigger.isUndelete)

        {

            System.debug(‘I am after Undelete’);

        } 

    }  

}

Our Recent Blog

Share This Post