Unique Page header captions to identify your envir... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Hi there,

Probably you've already got different instance themes and CSS in place, and maybe you've even got different favicons in place to easily identify the Instance you are working on. Though what about the Page header caption? Some will have this preserved during clones, some will manually change this every System Clone, some just made this generic so it doesn't need updating…
What if we could automate this, and make it unique, and maybe add a date stamp from the last System Clone?

A small heads up to make your ServiceNow life a little bit easier 🙂

Page header caption

This is what we are after:

find_real_file.png

The Page header caption (and Browser tab title) can be manually set through the System Configuration (System Properties > Basic Configurations UI16).

find_real_file.png

Notice that we are using a unique Page header caption which contains the Instance type, and the last System Clone date. Also we've set the Browser tab title.

Pre-requisite

Unfortunately, out-of-the-box there are no System Properties or what so ever that you can use to identify which type of Instance you are on. Are you on a Production Instance? An Acceptance Instance? A Development Instance? There is one System Property though, which is helpful: "instance_name". This System Property contains the name of the current Instance.

What we came up with, adding System Properties for all of you Instances. In our case, three System Properties: Production, Test, Development.

find_real_file.png

With these System Properties available, we could always check which Instance we are working on. Simply by checking which System Property matches the value of out-of-the-box System Property "instance_name".

Note: During System Clones, System Property "instance_name" is preserved by Clone Data Preserver "Core Instance Properties"

Time to automate

Goal of what we want to automate is that after System Clones, no manual work has to be done to update the Page header caption (and Browser tab title). The Page header caption should contain a copy of the name how it's on your Production Instance, with added the type of Instance, and the timestamp of the last System Clone.

To automate this, you can set up a "Clone Cleanup Script". The actual script looking like:

 

var grSystemProperty = new GlideRecord('sys_properties');
grSystemProperty.addEncodedQuery('nameSTARTSWITHinstance_name.^value=' + gs.getProperty('instance_name'));
grSystemProperty._query();

if(grSystemProperty._next()) {
	var titleStr = gs.getProperty('glide.product.description');
	var tabStr = '';
	
	var instanceStr = grSystemProperty.name.split('.')[1].toUpperCase();
	var date = new GlideDate().getByFormat(gs.getProperty('glide.sys.date_format'));
	
	gs.setProperty('glide.product.name', tabStr + ' ' + instanceStr);
	gs.setProperty('glide.product.description', titleStr + ' [' + instanceStr + ' - Last Cloned: ' + date + ']');
}

After a System Clone, the Page header caption on your Cloned Instance would contain the Page header caption as it is on your source Instance (Production) and added with the type of Instance and the last System Clone date, formatted according to your Instance date format setting.

---


And that's it. Hope you like it. If any questions or remarks, let me know!

👍
If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.

Interested in more articles, blogs, videos, and Share projects on System Clone / Upgrades I published?
- System Clone / Upgrades


Kind regards,
Mark

---

LinkedIn

Comments
Max Nowak
Tera Guru

Disclaimer: I haven't actually tested the code, so I apologize in advance if I'm missing something here, but wouldn't this:

[...]
var titleStr = gs.getProperty('glide.product.description');
[..]
gs.setProperty('glide.product.description', titleStr + ' [' + instanceStr + ' - Last Cloned: ' + date + ']');

result in always appending to the property 'glide.product.description' infinitely, every time this script runs?

 

First run: Service Management [DEV - Last Cloned: XX-XX-XXXX]

Second run: Service Management [DEV - Last Cloned: XX-XX-XXXX] [DEV - Last Cloned: YY-YY-YYYY]

Third run: Service Management [DEV - Last Cloned: XX-XX-XXXX] [DEV - Last Cloned: YY-YY-YYYY] [DEV - Last Cloned: ZZ-ZZ-ZZZZ]

And so on.

Snow User4
Tera Contributor

@Mark Roethof 

We are unable to set the Page header caption in Tokyo version after upgrade, can you please suggest the alternative way

 

Thank you.

Version history
Last update:
‎07-23-2019 08:25 AM
Updated by: