
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
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, smarter.
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
Recommended System Properties and User Preferences
In the previous blog, we've already made a small step with setting up a personal user account which we can use over and over on a PDI. Let's take a larger step: setting up System Properties and User Preferences. Both of which you could use on your PDI, though actually also on company/customer non-production instances. How annoying and time-consuming is it, to have to set up this all over again, again and again?!
System Properties
Let's list some System Properties we are after:
- glide.debug.log_point
When this property is true, you can use the logpoints feature which has been added in the Orlando release. Default is false or not present.
- sn_g_app_creator.allow_global
When this property is true, it will allow you to created global applications. Default is false.
- glide.invalid_query.returns_no_rows
When this property is true, invalid queries containing invalid or undefined field names always return no rows. Default is false.
- glide.email.test.user
All email will be sent to this email address. A small pre-caution for your PDI, might you turn on email sending.
Obviously, you could extend this list enormously. For example looking at the ServiceNow instance hardening guide, tens of System Properties are listed! The above ones though would benefit you greatly on a PDI and on company/customer non-production instances.
Note: Read about logpoints in one of my ServiceNow Community articles: Forget about adding log statements to Server Side script, use logpoints! [Orlando]
You could add these System Properties to an Update Set. Obviously you could also use an XML for this, or a Fix Script. That's up to you. I would keep these separated from the template user record from the previous blog, as the template user record would only fit your PDI while these System Properties could be used on company/customer non-production instances.
User Preferences
A real time saver and an annoying one: Having to set up your user preferences all over! Make a list of your common valuable user preferences. For example:
- glide.ui.application_picker.in_header
- glide.ui.update_set_picker.in_header
- glide.ui.related_list_timing
- rowcount
- com.glideapp.dashboards.homepage_notification.dont_ask_me_again
- home_refresh
- table.highlighting
You could also add user preferences for the ordering on lists. For example:
- syslog.db.order.direction
- syslog.db.order
- sys_update_xml.db.order.direction
- sys_update_xml.db.order
User record
On company/customer instances you probably would be given a personal user account. A user record created by an administrator, and therefore different than the template you've setup. How annoying is it, that the preferred language, time zone, date format are off!
UI Lists
A common action would be to personalize certain lists, maybe even view specific. For example:
- sys_update_xml
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.
The start of the Fix Script would contain defining which user it concerns. The logged-in user, so your user record.
(function() {
var userSysId = gs.getUserID();
})();
Updating the user record settings like preferred language, timezone, date format.
var grUser = new GlideRecord('sys_user');
grUser.get(userSysId);
grUser.setValue('preferred_language', 'en');
grUser.setValue('time_zone', 'Europe/Amsterdam');
grUser.setValue('date_format', 'dd-MM-yyyy');
grUser.update();
Adding personalized lists.
var grPersonalizeList = new GlideRecord('sys_ui_list');
grPersonalizeList.addQuery('sys_user', userSysId);
grPersonalizeList.deleteMultiple();
var personalizelistObj = [
{
'name' : 'sys_update_xml',
'parent' : '',
'view' : 'Default view',
'element' : 'type, target_name, name, action, update_set, sys_updated_by, sys_updated_on'
},
{
'name' : 'sys_update_xml',
'parent' : 'sys_update_set',
'view' : 'Default view',
'element' : 'type, target_name, action, sys_updated_by, sys_updated_on'
}
];
for(var i = 0; i < personalizelistObj.length; i++) {
var grPersonalizeList = new GlideRecord('sys_ui_list');
grPersonalizeList.initialize();
grPersonalizeList.setValue('name', personalizelistObj[i].name);
grPersonalizeList.setValue('parent', personalizelistObj[i].parent);
grPersonalizeList.setValue('sys_user', userSysId);
grPersonalizeList.setValue('view', personalizelistObj[i].view);
grPersonalizeList.insert();
var elementArr = personalizelistObj[i].element.split(',');
for(var j = 0; j < elementArr.length; j++) {
var grPersonalizeListColumn = new GlideRecord('sys_ui_list_element');
grPersonalizeListColumn.initialize();
grPersonalizeListColumn.setValue('element', elementArr[j].trim());
grPersonalizeListColumn.setValue('position', j);
grPersonalizeListColumn.setValue('list_id', grPersonalizeList.getUniqueValue());
grPersonalizeListColumn.insert();
}
}
Inserting user preferences.
var grUserPreference = new GlideRecord('sys_user_preference');
grUserPreference.addQuery('user', userSysId);
grUserPreference.deleteMultiple();
var userpreferenceObj = [
{
'name' : 'glide.ui.application_picker.in_header',
'value' : 'true'
},
{
'name' : 'glide.ui.update_set_picker.in_header',
'value' : 'true'
},
{
'name' : 'glide.ui.related_list_timing',
'value' : 'deferred'
},
{
'name' : 'rowcount',
'value' : '100'
},
{
'name' : 'syslog.db.order.direction',
'value' : 'DESC'
},
{
'name' : 'syslog.db.order',
'value' : 'sys_created_on'
},
{
'name' : 'sys_update_xml.db.order.direction',
'value' : 'DESC'
},
{
'name' : 'sys_update_xml.db.order',
'value' : 'sys_updated_on'
},
{
'name' : 'com.glideapp.dashboards.homepage_notification.dont_ask_me_again',
'value' : 'true'
},
{
'name' : 'home_refresh',
'value' : 'off'
},
{
'name' : 'table.highlighting',
'value' : 'false'
}
];
for(var i = 0; i < userpreferenceObj.length; i++) {
var grUserPreference = new GlideRecord('sys_user_preference');
grUserPreference.initialize();
grUserPreference.setValue('user', userSysId);
grUserPreference.setValue('name', userpreferenceObj[i].name);
grUserPreference.setValue('value', userpreferenceObj[i].value);
grUserPreference.insert();
}
After running the above script, al of the mentioned user settings, personalized lists and user preferences would be updated/generated for the account on which you are logged in.
Favorite Favorites
With the System Properties and User Preferences (and some user record settings and personalized lists) we've made a really nice step in provisioning your PDI or company/customer non-production instance and your personal user account. Next up would be another really annoying one... Favorites!
Keep an eye out for the next blog where I'll write about setting up your favorite Favorites 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? |
Kind regards,
Mark Roethof
ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP
1x ServiceNow Community MVP
---
- 1,843 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.