You need to sign in to do that
Don't have an account?
Harsha Sekhar
when trigger.new returns more than one record
Hi Guys,
Is it possible that Trigger.new(returns list<Sobject>) returns more one record. If its possible can someone explain when it will.
Thanks
Harsha
Is it possible that Trigger.new(returns list<Sobject>) returns more one record. If its possible can someone explain when it will.
Thanks
Harsha
Greetings to you!
Trigger.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.
For example, in this simple trigger, Trigger.new is a list of sObjects and can be iterated over in a for loop. It can also be used as a bind variable in the IN clause of a SOQL query.
Trigger.new contains the records that caused the trigger to fire. Triggers can fire when one record is inserted, or when many records are inserted in bulk via the API or Apex. Therefore, context variables, such as Trigger.New, can contain only one record or multiple records. You can iterate over Trigger.New to get each individual sObject.
Please refer to the below links which might help you further with the above requirement.
https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers/apex_triggers_intro
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas