You need to sign in to do that
Don't have an account?

Which will execute first
Hello as we all know that customer validation excute first and then before trigger .
so I write a trigger to show error message if description is null
trigger updatecontact on contact( before trigger)
for(contact con: trigger new)
If(con.description == null)
Con.adderror(' message from trigger i.e contact is null')
And wrote a custom validation for the same thing
so I write a trigger to show error message if description is null
trigger updatecontact on contact( before trigger)
for(contact con: trigger new)
If(con.description == null)
Con.adderror(' message from trigger i.e contact is null')
And wrote a custom validation for the same thing
When I try to save the code its showing message from before trigger not from custom validation .
Why so . Please help I'm confused
Why so . Please help I'm confused
please check the for Loop.. in your code.
for(contact con: trigger new)
It should changed to for(contact con: trigger.new)
as per my Observation from your code.
If you have wrote any Custom Validition for the same please deactivate it and try.
Note: Any requirement can be solved through validations or with any automations try to follow them only. In case of requirement cannot be solved through these validations, worlflows, proccesbuilder etc. then try using Triggers. Its a good practice.
Thanks & Regards,
Prasanthi
If My Answer was helpful please mark it as Best Answer.
Thank in Advance,
Prasanthi
Executes all before triggers First then,Runs most Custom validation.
For Help please go through the below link.
https://www.apexhours.com/order-of-execution-salesforce/
Thank You,
Bhavitha
please go through the below link also,
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
If you find helpful,
Please mark it as best answer.
Thank You,
Bhavitha