Next experience greenting message

NS16
Mega Sage

Hi Experts,

Requirement- On user table we have custome "xyz" field(string field), and client wants that field should be visible everywhere user first name is visible in native UI.

e.g. 

1) When itil user login, they are landing on workspace and there is this greeting message so instead of first name of user client wants "xyz" field value should populate there.

 

NS16_1-1702334195050.png

2) Admin view- 

NS16_2-1702334244513.png

So basically in native UI we need to change greeting message, instead of "Hello ITIL!" or "Welcome to Admin Home, System!" is should show "xyz field value".

Note- We have changed display value of user table from "Name" to "xyz" field.

 

Thanks in Adavance,

NS

 

 

3 REPLIES 3

Giorgio Pereira
Tera Contributor

Hello! I know this post is a bit old but recently I had the same issue and we did not find any documentation on how to translate this specific message, however I have figured a way to fix this by using the F12 web tool to trace where this text is created.

 

Turns out it's in a UX Client Script (sys_ux_client_script table) called "stylized_text_4/text" on the application "Admin Center" and Macro Component "Admin Next Experience Landing Page". The script follows as below:

 

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {TransformApiHelpers} params.helpers
 */
function evaluateProperty({
    api,
    helpers
}) {
    const name = api.context.session.user.firstName || api.context.session.user.fullName;
    const greeting = helpers.translateSync('Welcome to Admin Home, {0}!', name);
    return greeting;
}

 

As we can observe, the greeting message is stored in the constant "greeting". Even though it uses the translateSync method, I did not find a way to make it work with the system Messages (sys_ui_message) by adding entries to each language.

 

After some tinkering, I have created the following code to check the language of the current user:

 

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {TransformApiHelpers} params.helpers
 */
function evaluateProperty({
    api,
    helpers
}) {
    var greetingMessage;
    if(api.context.session.user.language == 'en'){
        greetingMessage = 'Welcome to Admin Home';
    } else{
        greetingMessage = 'Bem vindo a Homepage do Administrador'
    }
    const name = api.context.session.user.firstName || api.context.session.user.fullName;
    const greeting = helpers.translateSync(greetingMessage + ', {0}!', name);
    return greeting;
}

 

As you can see, all I did was to create a new variable called greetingMessage containing the message accordingly to it's respective language, in our case we only have to check if the current user is using english by using the attribute api.context.session.user.language, if the user language is EN it will show the default english message, else it will show the message in Brazilian Portuguese.

 

There may be better ways to translate this field, perhaps by using the translateSync method, but since this whole script and methods are not very well documented we have stick with the solution above.

 

I hope this answer helps anyone who find themselves with similar issues.

 

Regards,

Thank you for your response ! How did you manage to find the script include with the web tool ? 

Kashif Wasim Sa
Tera Contributor

Hello, I'd like to inquire about the possibility of updating the greeting from "Hi firstname" to "Hi Preferred name." The preferred name field exists in the sys_user table; however, it's not currently accessible in the script. I'm uncertain whether we can reference the sys_user table in this script to make the preferred name available for selection. I would appreciate your response on this matter. Thank you.