function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amith RaoAmith Rao 

what are Trigger Context variables?

ayu sharma devayu sharma dev
Hello Amith,
This blog is really good to read about Trigger Context Variable: 
https://www.sfdcpoint.com/salesforce/trigger-context-variables-in-salesforce/

Let me know if you need any further information, thanks.
Malika Pathak 9Malika Pathak 9

Hi Amith Rao,

please find the solution

Trigger context variables


All triggers define implicit variables that allow developers to access run-time context. 
These variables are contained in the System.Trigger class.
 isExecuting
 isInsert
 isUpdate
 isDelete
 isBefore
 isAfter
 isUndelete
 new
 newMap
 old
 oldMap
 operationType
 size


 https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm
 https://www.sfdcpoint.com/salesforce/trigger-context-variables-in-salesforce/

 

SwethaSwetha (Salesforce Developers) 
HI Amith,
I recommend reading https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm


Trigger.new can be accessed in insert, update and undelete triggers, and the records can only be modified in before triggers.
Trigger.old can be accessed in the update and delete triggers.

All triggers define implicit variables that allow developers to access run-time context. These variables are contained in the System.Trigger class.
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. 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.

Happy to answer any follow-up queries.
​​​​​​​Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Amith RaoAmith Rao
Thankyou swetha, Malika And ayu sharma for your answers to help me with.