Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jim Coyne
Kilo Patron
Included in the Developer Toolbox Update Set available on Share (link to Share in the post).

 

Here's a nice productivity booster.  I've been working on a bunch of Catalog Items lately and many of them have Select Box variables with a bunch of choices to select from.  The choices were supplied in an Excel spreadsheet so it was easy to copy/paste them into ServiceNow, but I wanted an easier way to add them to the variable.  Wouldn't it be nice to just copy and paste them?

 

Well, after some thinking, I came up with a UI Action and UI Page combination that allows a user to paste a bunch of choices all at once and have them added automagically.  Here's the Related Link UI Action on the Variable form when the "Type" field is set to "Select Box":

 

JimCoyne_0-1691693430892.png

 

And here is the popup UI Page:

 

JimCoyne_1-1691693456379.png

 

The UI Page has a number of options to choose from:

Option Description

How is the data separatedEither "Comma-separated string" or "One entry per line".The selection depends on your source data.
Start Order atThe number you want to start the "Order" field at for the first choice item.
Increment byThe number you want the "Order" field to increase by for each new choice item.
Leave at 0 (zero) to sort your items alphabetically.
Include NULL option?If selected, will add a new choice item with a value of "NULL" which will then override the "-- None --" option normally seen.
NULL selection textThis will be the text used when overriding the "-- None --" option. 
Use the same string for the 'Value' fieldWhen selected, the strings entered in the text box will be used in both the "Value" and "Text" fields on the Question Choice records.  Otherwise, a lowercase version of the strings will be used, with all non-alpha numberic characters being converted to the underscore character (_).
"Add 'NULL / Yes / No' Choices" buttonWhen clicked, will set the options above to add a set of NULL/Yes/No choices.

 

The resulting list of Question Choice records would look like this if "OK" was clicked in the above screenshot:

 

JimCoyne_2-1691693544202.png

 

And the Select Box variable would end up looking like this when ordering from the catalog:

 

JimCoyne_3-1691693587519.png

 

The "Please select..." item appears first in the list because of it's Order of "0" and the others sorted alphabetically because they all have an Order of "100".  Select Box variables will display the Question Choice records sorted by Order and then alphabetically within the same Order.  Makes it easy if you want a sorted list but no need to set each "Order" individually.

 

I've attached XML files for you to import into your instance:
- the UI Action
- the UI Page
- an Access Control record that allows access to the UI Page
- an Access Role record that only allows the "admin" role to access the UI Page
- UI Messages for any text users will see

 

TIP: import the Access Role record before the Access Control record, otherwise the system may add "snc_internal" to the "Requires role" list.

 

NOTE: Remember, always a good idea to try it out in your company's development instance first, or better yet, your own personal development instance. 

3 Comments