Change display name on Service Operations workspace landing page

Kashif Wasim Sa
Tera Contributor

Hello all,

I am attempting to update the homepage of the Service Operations Workspace to display the preferred name instead of the first name in the banner that currently says Hello <first name of user>. We have a custom field in the sys user table that stores the preferred name. I've tried to make these changes following the steps by navigating to UI Builder -> Service Operations Workspace -> making a copy of the existing landing page -> adjusting the greeting under client scripts -> Initial Transactions.
However it seems that the first name is captured via client script using < api.context.session.user.firstName > that does not retrieve the preferred name because it's not querying the sys user table.

Is there a way we can query user table so it can pick up preferred name.

 

Thank you

16 REPLIES 16

RaghavMuthyam
Tera Guru

Hi @Kashif Wasim Sa ,
We had a similar requirement to display the full name. We updated the client script to fetch the full name using <api.context.session.user.fullName>.
Also, it retrieves the current session user's sys_id using <api.context.session.user.sys_id>. You can use this data to query the custom field. 
Hope it helps. 

Accept and hit Helpful if it helps.

Thank you,
Raghav.

Haseeb-Ahmed
ServiceNow Employee
ServiceNow Employee

Hi @Kashif Wasim Sa ,

As you have already explored that "api.context.session.user" does not have all fields available, as suggested by @RaghavMuthyam we may utilize "api.context.session.user.sys_id" to retrieve your custom fields.

To do so you may follow below steps

1. you may create new data broker of type "look_up_a_single_record" and pass Table as "sys_user" and Record as "api.context.session.user.sys_id", which will return all fields in json

2. you can utilize output of this data broker in client script to populate greeting message having custom field value

refer screenshot

Screenshot 2024-08-02 at 12.28.04 PM.png

 

Please mark it helpful if it answers your query.

Thanks,
Haseeb Ahmed

 

Hi @Haseeb-Ahmed  , Thank you for your response. I followed the steps but am having trouble locating the record "api.context.session.user.sys_id". Is there a specific method I should use to find it?

Community Alums
Not applicable

Hi @Kashif Wasim Sa ,

Please go through this document to know how to locate api in UI Builder: https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...