+ Start a Discussion
Deepak G 9Deepak G 9 

if country is japan i need currency as japanese yen

Hi All,
When a new User is being created and the Country = USA, the Currency field should default to USD.
we dont have a country field we have only address field.
Kindly help me to write the below trigger.
 
trigger Default_Currency_toUSD On User (before insert) 
{  
 public address add;
   for(User objUser: Trigger.new)
 add=objUser.Address;
    If(add.contains('USA'))
    {
    
    //User.DefaultCurrencyIsoCode='USD';
    
    }  

}
Thanks,
Deepak
 
Best Answer chosen by Deepak G 9
Maharajan CMaharajan C
Hi Deepak,

Try the below code and let me know:

trigger Updatecurrency on User (before insert, Before Update) 
{
for(User u:trigger.new)
{
IF (u.country=='USA') 
{
u.DefaultCurrencyIsoCode='USD';
}
}
}

If this solve your problem choose this as best answer!!!

Thanks
Raj