+ Start a Discussion
ifthikar ahmedifthikar ahmed 

Trigger clarification

I am new to sales force

My trigger is for the Lead , PFB for the Trigger

trigger HelloWorld on Lead (before update) {
    for (Lead l : Trigger.new){
        l.FirstName = 'Hello';
        l.LastName = 'World';

once after saving this when i go to lead and just select the record. immediately the f.name and l.name is getting changed to Hello world.... i have not even done any changes more over didnt click on the save button also..

To my understanding trigger shuld execute only if i make any change in the record or even while just viewing the record by clicking on its name itself will the trigger gets executed as it is a before trigger

Please refer the lik below. The behaviour mentioned in the below link is intermittently observed in your scenario as well.


Please hit like if this suffice your question
Ajay K DubediAjay K Dubedi
Hi Ifthikar,
I think you have some misunderstanding because you write a trigger on update event and it only fires when you update the Lead.
I try your code in my ORG and it works fine when I update the particular Lead.
For more info about trigger you need to follow the below link:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi
ifthikar ahmedifthikar ahmed
Hi Yogesh, Thank you for your reply.. So i could understand that the update trigger is getting executed automatically even when a change is not made in the record, is it a sort of bug or something ... My observation was correct ?