User Language: User Preference vs User Profile

jamesmcwhinney
Giga Guru

Our end users will be primarily accessing our servicenow instance via our ESS portal.

On the ESS portal, there is a "My Profile" section which allows the user to change their language.

Initially, this works fine.

When happens next is that at some point a user finds them self on the main portal.   Once on the main portal, the user then changes their language via the gear icon which creates a personal preference which now overrides the language in the "My Profile" area, rendering it meaningless.

What is the best way to prevent this, and ensure a consistent language setting via both ESS and the main portal?

Thanks,

- James

1 ACCEPTED SOLUTION

jamesmcwhinney
Giga Guru

Please disregard the earlier questions, I ended up fixing this via 1 business rule against the sys_user_preference table that will update the user's profile and cancel the attempt to create the user preference:




Name: Sync User Profile Language


Table: User Preference [sys_user_preference]


Advanced: yes


When: before


Insert: Yes


Update: Yes


Filter Conditions: When Name is "user.language"


Script:


function onBefore(current, previous) {


    //Update the user's profile and block the creation of a user preference


  gr = new GlideRecord('sys_user');


  gr.addQuery('user_name',current.user.user_name);


  gr.query();


  while (gr.next()) {


  gr.preferred_language = current.value;


  gr.update();


  }


  current.setAbortAction(true);


}


View solution in original post

6 REPLIES 6

This is not working on my side.

Bharath73
Tera Contributor

Hello James,

Did you try creating a business rule against user profile to update user.language in preference record?