How to set tab title after page has been loaded

Martin76
Kilo Expert

Hi,

I'm trying to figure out how to change the depicted tab title from the default "Loading…" to a dynamically generated text that is known just after a data resource on the page has been loaded.

My contacts at ServiceNow believe there must an event that can be emitted to change the title so I assume I must call something like this to set it:

api.emit("NOW_UXF_PAGE#AN_EVENT_NAME", "My new title")

However, I couldn't find the list of available events anywhere.

Has anyone come across this issue? Did you find anything in the documentation? Our users would like to see a meaningful text in the title.

Thank you,
Martin

find_real_file.png

1 ACCEPTED SOLUTION

In my case, this only changes the browser title, not the workspace tab title:

find_real_file.png

However, your idea made me explore the API a bit further and finally I found this to work (almost) as expected:

helpers.screen.updateStatus({title: "My new title"});

This will set both the title of the browser and of the workspace to "My new title".
However, it doesn't work after you do a Link to destination if your target route is "current". (because it creates some kind of a subroute). But that's a different issue.
Thanks once again, this at least answers the original question.

View solution in original post

4 REPLIES 4

Muhammad Khan
Mega Sage
Mega Sage

Hi Martin,

 

I remember to come across this issue as well. You can try the following solution which might work for you or at least give you a direction. I have created Row Clicked event on my list, where I have specifically selected Link to destination event, which is redirecting me to this Testing page.

As you can see the tab Title is set to Loading...

find_real_file.png

The reason for this is the Title field in Link to destination event is not set, as you can see in the below image.

find_real_file.png

After specifying either the hardcoded or dynamic value via binding, it will be resolved. Make sure to Apply and save. See the below images for reference.

find_real_file.png

find_real_file.png

 

Hopefully, this will resolve your query.

Hi Muhammad,

thank you a lot for posting this. I have found this option - but that still requires me to know the title value before the page is loaded. This could work when navigating from a list, but the user might as well just paste the URL from clipboard or open it in another way. 
Your workaround would certainly cover some cases but it's not a proper solution (imho).
Thanks anyway.

Then, try adding Page ready event and add the Title over there, as shown in the images below.

find_real_file.png

find_real_file.png

Hopefully this will resolve your query.

In my case, this only changes the browser title, not the workspace tab title:

find_real_file.png

However, your idea made me explore the API a bit further and finally I found this to work (almost) as expected:

helpers.screen.updateStatus({title: "My new title"});

This will set both the title of the browser and of the workspace to "My new title".
However, it doesn't work after you do a Link to destination if your target route is "current". (because it creates some kind of a subroute). But that's a different issue.
Thanks once again, this at least answers the original question.