You need to sign in to do that
Don't have an account?
Sunny Sohail
Trigger to override "Billingstate" on accounts object.
Hello,
I am fairly new to writting triggers and have a question regarding overiding fields via trigger. Basically what I wantr to happen is to force users to input a "billingstate" using the 2 letter abbreviation. For example if someone inputs "UTAH" I want the "Billingstate" to update to "UT". I know that this is somewhat possible using validation rules but I really want to understand how this is done via trigger. The below is a simple code that will only affects accounts in Utah and this is what I have, but this code does not seem to work. Basically the below code should force the state to update "UTAH" to "UT" upon creation and upon update to the record.
trigger ForceAccountstate on Account (before insert,after update) {
for (Account AccountInLoop : Trigger.new) {
if (Billingstate = UTAH)
Billingstate = 'UT';
}
}
I am fairly new to writting triggers and have a question regarding overiding fields via trigger. Basically what I wantr to happen is to force users to input a "billingstate" using the 2 letter abbreviation. For example if someone inputs "UTAH" I want the "Billingstate" to update to "UT". I know that this is somewhat possible using validation rules but I really want to understand how this is done via trigger. The below is a simple code that will only affects accounts in Utah and this is what I have, but this code does not seem to work. Basically the below code should force the state to update "UTAH" to "UT" upon creation and upon update to the record.
trigger ForceAccountstate on Account (before insert,after update) {
for (Account AccountInLoop : Trigger.new) {
if (Billingstate = UTAH)
Billingstate = 'UT';
}
}
Check below commts in code you will find the solution .
Let me know if it helps
Thanks
Manoj
All Answers
Try with below code it wil help !!
Let me know if it helps
Thanks
Manoj
Try with below code it wil work . LEt me know if it helps !!
Thanks
Manoj
Check below commts in code you will find the solution .
Let me know if it helps
Thanks
Manoj