Automatic Update Set and STRY Linkage
If you are using ServiceNow’s built-in agile capabilities, you might find this article helpful!
The goal of this article is to create an automatic link between STRY records and Update Sets. This way, when we look at stories, we can quickly pinpoint exactly where the changes happen. This makes it a lot easier to code review other developers’ work and ensure we are checking all of our boxes.
Let’s dive right in:
Story [rm_story] updates
Only two actions are required on the the Story [rm_story] table:
- Create a list collector field that points to the Update Set
[sys_update_set]table - Update the form layout of your Story form to display the list collector where you want it
Creating the Business Rule
Next, we’ll create a business rule on the Update Set [sys_update_set] table.
Configurations
I’ve set this up to run after insert or update. You can also set it to include delete if you want. Lastly, I have a condition to ensure the name of the update set contains STRY:

Script
In the Advanced tab, pop in the following code. Thanks ChatGPT. Make sure to use the name of your field that you created on the Story [rm_story] field – mine’s called u_related_update_sets.
NOTE: The script below does not check if your update set is already linked to the story; as a result, you may see duplicate update sets listed on your STRY records. I no longer have access to the updated script that performs this check. But it’s pretty simple to add; basically, you just need to add a line that checks if the current sys_id is already present with the if(storyGR.next()) { statement.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
// Check if the sys_update_set name contains 'STRY'
if (current.name.indexOf('STRY') !== -1) {
// Extract the STRY number
var stryNumber = current.name.match(/STRY\d{7}/);
if (stryNumber) {
// Query the rm_story table for the STRY record
var storyGR = new GlideRecord('rm_story');
storyGR.addQuery('number', stryNumber[0]);
storyGR.query();
if (storyGR.next()) {
// Update the related_update_sets field
var relatedUpdateSets = storyGR.u_related_update_sets.toString();
if (relatedUpdateSets) {
relatedUpdateSets += ',' + current.sys_id;
} else {
relatedUpdateSets = current.sys_id;
}
storyGR.u_related_update_sets = relatedUpdateSets;
storyGR.update();
}
}
}
})(current, previous);Output
Try creating or updating an update set that you have a story for! You should see the list collector populate like below.

Enjoy!