Notification variable not getting translated

Kevin Paul
Mega Guru

Hi,

For translation of notifications, we have created notification in each language(french and english). For one of the french notifications, there are variables added in the message body. This notification is created in the sc_request table.

find_real_file.png

I have changed the language of the recipient to french in the user table and as well as changed the language in profile to french. Look at the image below, the ui is now in french. The field impact's value is translated here.

find_real_file.png

 

However when the notification is triggered, you can see the word, 3 -Medium is not translated. The same word is translated as 3 â€“ Modérée in the above image, which is taken from the sc_request table from which the variable is used in the notification record.

find_real_file.png

 

How to fix this and translate that variable's value. The translated value is already available in the sys_choice table, but why it does not appear in the notification still remains unclear (language is set to french both in the user table and in the preferences table) .Any workaround/help is appreciated.

Thanks in advance!

26 REPLIES 26

Jaspal Singh
Mega Patron
Mega Patron

Hi Kevin,

 

Try below.

1. Create a mail script as below

name: gettranslatedimpactvalue

(function runMailScript(current, template, email, email_action, event) {

        var getreq=new GlideRecord('sc_request');
	getreq.addQuery('sys_id',current.sys_id);
	getreq.query();
	if(getreq.next())
		{
			var impactis=getreq.impact;
			var getimpacttranslated=new GlideRecord('sys_choice');
			getimpacttranslated.addQuery('element','impact');
			getimpacttranslated.addQuery('name','task');
			getimpacttranslated.addQuery('language','es'); //replace es accordingly here
			getimpacttranslated.addQuery('value',impactis); //considering impactis returns value as 1,2 or 3 or so
			getimpacttranslated.query();
			if(getimpacttranslated.next())
				{
					template.print(getimpacttranslated.label);
				}
		}

})(current, template, email, email_action, event);

 

Replace ${impact} in the notification as ${mail_script:gettranslatedimpactvalue}

 

Above it untested but should work ideally.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Did you check in the actual email body instead of preview?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

This is not the preview notification, preview notification works fine. The actual mail triggered in the mail table does not translate

Kevin Paul
Mega Guru

Is there no other way around for this? why does one variable not get converted when other variables are getting converted? 

@Alex Coope need your input on this