You need to sign in to do that
Don't have an account?
Usha Charles 3
Validation - Account Creation
Hello,
I am trying to create a validation on Account creation using a trigger (Just to learn APEX). I want only the users with Locale US/UK to be able to create accounts in UK/US & block the others. below is my code. but is dosent seem to be working as I get the error message for all users not just the ones with locale UK/US.
Can Someone please tell me what am I missing here?
Thanks,
I am trying to create a validation on Account creation using a trigger (Just to learn APEX). I want only the users with Locale US/UK to be able to create accounts in UK/US & block the others. below is my code. but is dosent seem to be working as I get the error message for all users not just the ones with locale UK/US.
Can Someone please tell me what am I missing here?
Thanks,
trigger ValidateAccount2 on Account (Before Insert, Before Update) { String UserLocale = userInfo.getLocale(); For(Account acc : Trigger.new){ If (acc.Country__c == ('UK') || acc.country__c =='US' && UserLocale != ('English - United States')){ acc.addError('You are not allowed to add Accounts to other Regions. Please contact your Sales Admin'); } } }
In the backend the locale values are stored as en_US. So your code will be like this
'
All Answers
In the backend the locale values are stored as en_US. So your code will be like this
'
Thanks a lot ! that solved the issue !