You need to sign in to do that
Don't have an account?
bonny mankotia
trigger new and old value compare
Hello guys.I have this simple trigger i need to compare old and new values for this trigger and if its not match then update the phone field.Can somebody sort out this problem with code?
trigger SameobjTrg on Contact (before insert)
{
for(contact con:trigger.new)
{
con.MobilePhone = '9816175515';
}
}
trigger SameobjTrg on Contact (before insert)
{
for(contact con:trigger.new)
{
con.MobilePhone = '9816175515';
}
}
You cann't get the old value in Before Insert opperation. Becuase you are going to insert something new in system which was not present in system than how can you get the old value,.
-Thanks
Ashlekh Gera
Before triggers are used to perform the logic on the same object .
If you want to updateing the records of the same object 'Before'' triggers are used.
After triggers are used to perform the logic on the related objects and these triggers are used access the fields values that are created by system (Ex: CreatedBy, LasteModifiedBy , Record Id etc..).
If your using "After " event you can get the error like this