- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2017 02:19 PM
Hey guys,
I wanted to know if it was possible to set the language of a service portal page in the link. I have a public portal, I'll be sending the link to access the ticket view by mail to users not registered in ServiceNow. I need to support 4 different languages (information that I previously have), and I would like to send in the link itself something that will make ServiceNow recognize the language. The other option is to have 4 pages, in that case what I need to know if it's possible to set the language of a particular page by default.
Any thoughts?
Thanks!
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2017 04:32 AM
Should basically put the language in a parameter in the url,
Then on the page have a widget with something like this in the server script:
var lang = $sp.getParameter('lang');//the URL parameter
var util = new I18nUtils();
util.setLanguage(lang);
but remember this will set the language for the whole session

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2019 09:22 AM
Hi,
yes that was more or less what wanted to do. I was wondering if there was a way to force the portal to open in a specific language but even if we set it at the very beginning of server script, it loads in the system English first. Guess I'll have to convince the client to either start with English or have some "animation" interceptor. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2017 05:42 PM
Thanks a lot larstange and goranlundqvist. I ended up entering in an existing widget the following code:
// Set the language based on the u_language field
var util = new I18nUtils();
var lang = gr.getValue('u_language').toString();
switch (lang) {
case 'ES':
util.setLanguage('es');
break;
case 'FR':
util.setLanguage('fr');
break;
case 'PT':
util.setLanguage('pt');
break;
case 'GB':
util.setLanguage('en');
break;
default:
break;
}
gr is my current record, I have over there a field with the language I need. And having it for the session is great, because that's the idea, to have an unauthenticated user to see the required information in the ticket's language.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2019 05:16 AM
Hi Guys,
I am trying to apply this, for an anonymous survey, but it does I cannot seam to set the condition correctly.
It looks like it always goes to
else if(lang != ''){
but then does not change the language (I am adding &lang=de at the end of the URL as the parameter)
the server script of the take_survey widget:
(function() {
var page_id = options.id || $sp.getParameter('id');
var typeId = options.type_id || $sp.getParameter('type_id');
var surveyId = options.instance_id || $sp.getParameter('instance_id');
var lang = $sp.getParameter('lang');
var sp = new SPSurveyAPI();
if (page_id == 'public_survey' && lang == '') {
if(!!typeId && (!sp.isSurveyPublic(typeId) || gs.isLoggedIn()))
data.redirectTarget = "?id=take_survey&type_id=" + typeId;
else if(!!surveyId && (!sp.isSurveyInstancePublic(surveyId) || gs.isLoggedIn()))
data.redirectTarget = "?id=take_survey&instance_id=" + surveyId;
}
else if (lang!=''){
var util = new global.I18nUtils();
util.setLanguage('lang');
}
sp.loadSurvey(typeId,surveyId, data);
})();
Do you have any suggestions for what I could be doing wrong?
Thanks!
Zhivko
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 06:34 AM
How did u resolved this issue, plz share your logic.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 07:02 AM
If I remember correctly, after London you just need to make sure you are using the latest oob widget. It is looking for a sysparm_lang parameter. I have added the &sysparm_lang=whateversyslanguageyouneed to the link in the notification email and that works.
If you are logged in, however, this will change your the language setting for your account, so I only use this for public surveys.