Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set username in header of Workspace

pverni
Tera Contributor

Hello everyone,

 

I'm trying to create a header in my new Workspace page and i would like to show the name of the current logged user in this header.

 

I tried to create a client state and client script:

pverni_2-1762382643964.png

 

 

pverni_1-1762382601400.png

And apply this in my header:

pverni_3-1762382668249.png

 

But the header is null (blank). I literally copy this process from the Business Continuity Workspace, but in my its not working.

 

Anyone can help me with this?

 

Thanks!

1 ACCEPTED SOLUTION

SVimes
Kilo Sage

I've got this working in my PDI. I had to change the client script to match the documentation rather than an example in the platform.

 

Documentation

 

Here is my example client script:

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 * @Param {any} params.imports
 * @Param {ApiHelpers} params.helpers
 */
function handler({
    api,
    event,
    helpers,
    imports
}) {
    helpers.translate('Hello, {0}!', api.context.session.user.fullName)
        .then((translatedText) => {
            api.setState('headerTitle', translatedText);
        });
}
Sable Vimes - CSA

View solution in original post

1 REPLY 1

SVimes
Kilo Sage

I've got this working in my PDI. I had to change the client script to match the documentation rather than an example in the platform.

 

Documentation

 

Here is my example client script:

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 * @Param {any} params.imports
 * @Param {ApiHelpers} params.helpers
 */
function handler({
    api,
    event,
    helpers,
    imports
}) {
    helpers.translate('Hello, {0}!', api.context.session.user.fullName)
        .then((translatedText) => {
            api.setState('headerTitle', translatedText);
        });
}
Sable Vimes - CSA