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
DJ 367DJ 367 

select Email template based on user's region

Hello All,

I have a custom javascript Button on OPPORTUNITY called SendEmail. I want to select my email template based on user's region. For example if user is from Germany ,german email template to be selected and if user region is USA ,english template to be selected. I am not sure how to achieve this and
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}

if('{!Opportunity.Id}' != null){
	if('{!Opportunity.SendEmail__c}' = true){
		//I need to select an email template based on user's region
	}
}

 which field to take into consideration from user object. Can someone please help me to achieve this.

Thanks
Somya SrivastavaSomya Srivastava
Hi,

You can use this :

var currentUser = sforce.connection.getUserInfo();
var result = sforce.connection.query('select LanguageLocaleKey from User where id=\''+currentUser.getUserId+'\'');

//once you have the value in result,then you can check as follows:
if(result == 'fr'){
//Your logic
}

Thanks
Somya