Provision your PDI or company/customer instances q... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Hi there,

 

So you are about to reset your PDI? Or requesting a new PDI? Logging in for the first time on your fresh instance, and… darn, I have to set up all kinds of settings, personal preferences, utilities, etc. all over again! Can we somehow get those settings, personal preferences, utilities back on the fresh PDI? How can we start quicker with a slightly personal provisioned PDI?

 

I'm writing a few short Community Blogs on this topic. To share with you, how I tend to provision my PDI quicker.

Some of these ideas could also apply for company/customer instances. For example, if you are working as a consultant you will be faced with several companies, new instances every year. Yes, also on these instances you can get a head start!

 

The topics which I'm going to share in the upcoming days:
Setting-up your personal user account
Recommended System Properties and User Preferences
- Favorite Favorites
Applying Plugins
Applying Utilities


Favorite Favorites

In the two previous blogs, we've set up a personal user account and a Fix Script to add Personalized Lists, System Properties and User Preferences. A really annoying piece when it comes to new instances… setting up your favorite favorites all over again!

Favorites

Make a list of your personal favorites. Some of mine for example:

- Customer Updates
Updated by me AND Updated on Last 7 days
- System Log
Created on Today
- Background Script
- Fix Script

Actually, I would like to group these. So it does not only concern the Bookmark records [sys_ui_bookmark], though also a Bookmark Group record [sys_ui_bookmark_group]. This is also a piece often missing on ServiceNow Community answers. Loads of answers that Favorites consist of sys_ui_bookmark records, though almost never, the sys_ui_bookmark_group records are mentioned!

Fix Script

Knowing the above, how can we turn this into an Update Set or XML? Actually in this case I would choose a Fix Script. Because you could run this also on a company/customer instance, where you have been given a personal user account. A personal user account, where the user record will have a different sys_id as the template you've set up for your PDI.

 

We could add the below script to the Fix Script of the previous blog.

 

var grBookmark = new GlideRecord('sys_ui_bookmark');
grBookmark.addQuery('user', userSysId);
grBookmark.deleteMultiple();

var grBookmarkGroup = new GlideRecord('sys_ui_bookmark_group');
grBookmarkGroup.addQuery('user', userSysId);
grBookmarkGroup.deleteMultiple();

var grBookmarkGroup = new GlideRecord('sys_ui_bookmark_group');
grBookmarkGroup.initialize();
grBookmarkGroup.setValue('title', 'Development');
grBookmarkGroup.setValue('user', userSysId);
grBookmarkGroup.setValue('color', 'normal');
grBookmarkGroup.insert();

var bookmarkObj = [
	{
		'icon' : 'list',
		'color' : 'green',
		'title' : 'Customer Updates > Me, Last 7 days',
		'url' : 'sys_update_xml_list.do?sysparm_query=sys_updated_by%3Djavascript:gs.getUserName()%5Esys_updated_onONLast%207%20days%40javascript:gs.beginningOfLast7Days()%40javascript:gs.endOfLast7Days()'
	},
	{
		'icon' : 'list',
		'color' : 'green',
		'title' : 'System Log > Today',
		'url' : 'syslog_list.do?sysparm_query=sys_created_onONToday%40javascript:gs.daysAgoStart(0)%40javascript:gs.daysAgoEnd(0)'
	},
	{
		'icon' : 'console',
		'color' : 'red',
		'title' : 'Background Script',
		'url' : '/sys.scripts.do'
	},
	{
		'icon' : 'console',
		'color' : 'red',
		'title' : 'Fix Script',
		'url' : '/sys_script_fix.do?sys_id=-1'
	}
];

for(var i = 0; i < bookmarkObj.length; i++) {
	var grBookmark = new GlideRecord('sys_ui_bookmark');
	grBookmark.initialize();
	grBookmark.setValue('group', grBookmarkGroup.getUniqueValue());
	grBookmark.setValue('user', userSysId);
	grBookmark.setValue('icon', bookmarkObj[i].icon);
	grBookmark.setValue('color', bookmarkObj[i].color);
	grBookmark.setValue('order', i + 1);
	grBookmark.setValue('title', bookmarkObj[i].title);
	grBookmark.setValue('url', bookmarkObj[i].url);
	grBookmark.insert();
}

 

This would already create your Favorites within a Group. By default, the group would be collapsed. So let's add below code to the User Preferences of the previous blog:

 

{
	'name' : 'favorite.' + grBookmarkGroup.getUniqueValue() + '.expanded',
	'value' : 'true'
},

 

After running the Fix Script and refreshing your browser, your Favorites would look like:

 

find_real_file.png

Applying Plugins

We made another nice step in provisioning your PDI or company/customer non-production instance with applying your favorite Favorites. Next-up: Applying Plugins.

 

Keep an eye out for the next blog where I'll write about applying your favorite plugins rapidly!

---


If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Quint Technology

1x ServiceNow Developer MVP

1x ServiceNow Community MVP

---

LinkedIn