
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
02-10-2023 06:54 AM - edited 02-10-2023 08:18 AM
Problem
ServiceNow scripting best practices recommend to avoid hardcoding strings in the code. One of the options to avoid that is to move them to system property and just retrieve the value in the code. (read more about strategies to avoid hardcoded values here).
Working with system properties might be annoying and repetitive task, though. And it is also prone to errors.
Errors may happen during the property name copy-paste or you can mistype the value retrieval statetement - gs.getProperty('property_name');
Solution
I had to script something today, which involved a bunch of properties and I created a simple UI action to copy the script usage to the clipboard.
Example
Let's take property that I created for my previous article:
Usual flow will be:
- go to the property definition
- copy the property name
- go to the target script
- type var defaultAssignee = gs.getproperty('')*;
- paste the propety name inside the quotes
With this little sugar, it is reduced to:
- go to our sys_property
- click 'Copy Script Usage'
- paste wherever needed in the code
You can download the tool from the Share.
If you find this article useful, hit the like button and consider subscribing to my content.
Please feel fee to reshare with your network as well.
Thanks for reading!
Martin Ivanov
Community MVP 2023
Developer MVP 2023
*Thanks for noticing! Yes, I know I have a typo in gs.getproperty('');, this is to show that typos hapeen all the time 🙂
- 1,048 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
when an incident move to Inprogress state then how to create 100 user information record ?