You need to sign in to do that
Don't have an account?
bonny mankotia
Trigger old and new value
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 = '98765436523';
}
}
trigger SameobjTrg on Contact (before insert)
{
for(contact con:trigger.new)
{
con.MobilePhone = '98765436523';
}
}
Your trigger is on Before Insert event. Their is old value when you insert any record. Hence it will not work to compare two values.
If you want to compare old and new value, you can do it in Update call. -Thanks,
TK
All Answers
Your trigger is on Before Insert event. Their is old value when you insert any record. Hence it will not work to compare two values.
If you want to compare old and new value, you can do it in Update call. -Thanks,
TK
Here is an example of comparing the old and new valuels in a trigger. For the scenario you mentioned above, you don't need a trigger. If the value is not changed, it won't update any way.