You need to sign in to do that
Don't have an account?
davidesi
Trigger.new operation
¿Can anybody explain me what is the operation of the Trigger.new ?
When I create an opportunity, for example, and a trigger is executed , Trigger.new shouldn't store ONLY that opportunity that I have created?
Why I get a lot of opportunitys in the Trigger.new collection?
Thanks
Thank you for your reply Vinit.
I knew that page that you have referred me, but I don' understand the behaviour.
If I add a Trigger wich is executed when it is created, isAfter , why am I getting more than 1 record in the list?
All Answers
Trigger.new is List which contains new versions of sobject on which the operation is being performed.Please find below link to know more :-
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm
Thank you for your reply Vinit.
I knew that page that you have referred me, but I don' understand the behaviour.
If I add a Trigger wich is executed when it is created, isAfter , why am I getting more than 1 record in the list?
Davi,
It is not that you are getting more than one record in the list.It is just that you have more than one values (I mean all the fields of that record,it is contained in the list).
So,it is the collection of all the values of that record ehich are stored in the list as Trigger.new.
Thanks Vinit.
In the trigger log , I see following line (it's only a line).
And every id belongs to an individual object.
PD: What is a Kudo?
When you print Trigger.new.You will see all the field values in the debug log.
What you are seeing is because the Trigger is running on multiple records.
As per Kudos ,it is the star ('*') button below my name in the my post.If you like the post,you can hit it to thank me.
That's what I don't understand.
If I am creating a single record, why that trigger runs over multiple records?
The trigger you see in Debug log is not on insert event,it is on update event.
updateRatecount on Choose_Rate trigger event BeforeUpdate for
I think what is happening here is that the record you are inserting , is updating any field available on these records causing the Update Trigger to fire.