Importing data into ServiceNow is an activity that administrators do often. I was helping a colleague recently and we came to the realization that while we were both familiar with the basics, there were a number of things we either didn’t know were possible or hadn’t had a chance to use before. In other words, even those of us experienced on the ServiceNow platform have things to learn.
I’ll try to document some of the #protip techniques you can use, but I’m sure that I’ll miss some — that’s where you come in, so sound off in the comments!
1. Referenced value field name
One of the coolest (and simplest) hidden features is the “Referenced value field name” option, which helps you map a value to a referenced field.
Let’s say you have the following table and you want to add the Manager for the people in the first column:
Person | Email Address | Manager | Manager email |
Beth Anglin | beth.anglin@example.com | David Loo | david.loo@example.com |
BOW RUGGERI | Bow.Ruggeri@example.com | Fred Luddy | fred.luddy@example.com |
richard berzle | rick.berzle@example.com | Rob Phillips | rob.phillips@example.com |
Robert | rob.phillips@example.com | Bow Ruggeri | bow.ruggeri@example.com |
Now, you’ll notice that the names include “Richard” and “Robert,” but that their email addresses don’t match the pattern. Additionally, the manager name for Richard is listed as “Rob Phillips,” but we only have him listed as “Robert” in the source person.
To get around this, we have to create (or open) the Field Map entry — we can’t use the “Auto map matching fields” or the “Mapping Assist” functionality.
When we open a field map and map to a reference-type field, an additional field shows up on our form — “Referenced value field name.”
For our example, we want the source field to be “Manager email” and the target field to be “Manager,” but we need to set the reference to be looked up upon the email attribute of the manager.
This will take the value of the source field and perform a query, not against the Display Value of the reference, which is the usual, but against the specified column instead.
Another common use case for this feature is importing CI data. For example, this feature can be useful if you have duplicate CI names but have a unique serial number.
2. Use source script
The second #protip here involves scripting, and it is one of the most powerful features of the Import mechanism in ServiceNow.
One of the best-practice rules is to make sure you only import clean data. However, this isn’t always possible. For example, you may get an HR data feed of users that looks a lot like mine. To help, we can use a little code to separate the first and last names:
And we can further sanitize our input and make everything Proper Case:
3. Make the Source script field have syntax checking
One of my pet peeves is that some script areas don’t have the script area tools, like syntax checking. This can be fixed easily by modifying the Dictionary for the field and making it a “Plain script” type.
NOTE: On Calgary and later you’ll have to modify the dictionary for “Dictionary [sys_dictionary] – Type [internal_type]” reference qualifier.
When we do that, we get the script box that we all know and love:
4. Delete files from FTP shares after ServiceNow processes them
Another simple, but very obscure option is to remove a file from an FTP server after ServiceNow has picked it up for processing. All it takes is adding the “Properties” field to the datasource form and setting the value to “remove_file=true.”
5. ZIP large files for faster transfers
In the screenshot above there is a checkbox for “Zipped.” This will let you ZIP a file for easier transfer or upload and ServiceNow will decompress the file before processing.
Since this feature is not well documented, here’s something to note: Only the file extension can change. This means that if your original file is named “users.csv” and you zip it, the zipped file must be named “users.zip”
With that, I’m certain that you have your own importing methods, so please share them in the comments!
The post ServiceNow Tech Tuesdays: 5 Importing #protips appeared first on Cloud Sherpas.