function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc G 9sfdc 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 sfdc 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