
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
07-24-2023 05:32 AM - edited 07-30-2024 10:00 AM
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Hi there,
When working on Instance Scan Scan Findings, wouldn't it be great to filter and analyze source records on when they were last updated and by whom they were last updated? Last updated, so we can sort on updated date, filter on for example updates from the last few days, last sprint, etcetera.
Out-of-the-box there is a "User" field available which is correct and holds the user_name of the user who last updated the artifact at the moment of scanning it, though there's no last updated (or there is... though that is about the Scan Finding record itself, not about the source record). Since the "Source" field is a Document ID type field, unfortunately dotwalking isn't an option in a list or on a form. So let's set up our own "Last updated".
Scan Finding
When looking at Scan Findings, out-of-the-box the list view looks like below (I did personalize columns, to add Updated).
Looking closely at the User column, the user_name in the User column is correct and is the last known user that updated the source record. The Updated field though is the last updated date of the... Scan Finding record, not the last update date of the source record.
Last updated
There are several ways thinkable of how to populate a custom Updated field. For example using a Flow or Business Rule, after insert of the new Scan Finding or upon completion of the Scan Result. For this article, we will go for a before insert Business Rule on the Scan Finding.
Perhaps good to mention, why a custom Updated field and why not updating the out-of-the-box Updated field? When updating the Scan Finding, for example adding a Scan Task or muting the Scan Finding, the User field will not be updated though the Updated field will. So that would overwrite the last updated date of the source record.
"Last updated"
To start with, we need to create a custom field on the Scan Finding table.
You might take this opportunity to clarify the User field also. My preference goes to renaming it to "Last updated by", though that's up to you 😀
We do have a custom Last updated field available now. Only it won't be populated with the last updated date/time yet. For this we can create a before insert Business Rule.
The script to use does not have to contain much. Basically querying the source record, and setting the custom last updated field. Since it's a before Business Rule, don't apply current.update().
(function executeRule(current, previous /*null when async*/) {
var grSourceRecord = new GlideRecord(current.source_table);
if(grSourceRecord.get(current.source)) {
current.u_last_updated = grSourceRecord.sys_updated_on;
}
})(current, previous);
Result
When executing any Scan Suites or Scan Checks from now on, the Last updated field will be populated with the a date/time of when the source record was actually last updated.
You might want to update the List layout and/or Form layout for Scan Finding. That's not included in this article or the Share project.
Share
An Update Set with this Topic Block can be downloaded from Share:
- Enhance Instance Scan Last updated (by)
---
That's it. Hope you like it. 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
Independent ServiceNow Consultant
4x ServiceNow Developer MVP
4x ServiceNow Community MVP
---
- 1,688 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very interesting! Any thoughts on the best way to tackle adding an 'Update Set' field that displays the Update Set of the record returning the scan check finding to the Scan Results?
Regards,
James