You need to sign in to do that
Don't have an account?
Trigger to update a field based upon the value in the look up
Hi,
I want update a currency field on Account to be in sync with the Account's Parent's Territory(Custom Object) Currency. Account has Territory as the lookup field.
I am not getting any errors but it is not working. If i see the system log it shows that the currency field is correctly assigned. Any thoughts?
My Code:
trigger UpdateCurrencyISOCode on Account (after insert, before update){
for(Account a : [Select id, CurrencyISOCode, Parent.Territory__r.CurrencyISOCode from account where id IN : trigger.new])
{
{a.CurrencyISOCode= a.Parent.Territory__r.CurrencyISOCode;}
}
Hello nnk,
after assinging the currencyISOcode are you updating the account ? and you should use before insert before update.
Hello,
one More suggetion is that you can do it using workflow also so try to do it with workflow.
We cannot use workflow as it does not have the option to update currency field, secondly if i use the after update event it goes in to recurssive loop.
Hello nnk,
i know that it will go to loop but you can put static class there and avoid the looping.
refer this link-- http://developer.force.com/cookbook/recipe/controlling-recursive-triggers
we cannot have e dml operation if we are using before update hence i cannot update th assignment of currency code.