- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 01:37 PM
We currently have 'Create Story' UI Actions on several Records that create a new Story Record and carries details from the initial Record over to the Story (IE: Description). After the creation of the UI Action, we've modified the Story form to display Reference fields for various records that the Story could be generated from.
What we are looking to achieve is, when the 'Create Story' UI Action is clicked from any record type, the parent Record Number populates in its corresponding reference field on the Story Record.
This is currently working for Enhancements (see below for UI Action Script which was created by the vendor we had worked with on implementation of ITBM), but we haven't been able to get this to work for Catalog Tasks, Ideas or Demands.
CREATE STORY ON CATALOG TASK
Action Name:
SCRIPT:
var story = new GlideRecord("rm_story");
story.short_description = current.short_description;
story.description = current.description;
story.priority = 4;
story.state = -5;
story.setValue("rm_story.u_reference_catalog_task", current.sc_task.number);
story.insert();
action.setRedirectURL(story);
CREATE STORY ON ENHANCEMENT
Action Name: create_scrum_story
Onclick: openFormDialog()
SCRIPT:
function openFormDialog() {
var sysId;
if (typeof rowSysId == 'undefined')
sysId = gel('sys_uniqueValue').value;
else
sysId = rowSysId;
var gModalForm = new GlideModalForm('Create Story', 'rm_story');
gModalForm.setPreference('sysparm_view', 'scrum');
gModalForm.addParm('sysparm_query', 'short_description=' +
g_form.getValue('short_description').replace(/\^/g, '^^') +
'^description=' + g_form.getValue('description').replace(/\^/g, '^^') +
//'^assigned_to=' + g_form.getValue('assigned_to') + commented so that Assigned to isn't copied//
'^classification=Feature' +
'^enhancement=' + sysId +
'^sys_class_name=rm_story'
);
gModalForm.setCompletionCallback(function(action_verb, sys_id, table, displayValue) {
if (action_verb == 'sysverb_insert') {
if (typeof GlideList2 !== 'undefined') {
if (GlideList2.get("rm_enhancement.rm_story.enhancement"))
GlideList2.get("rm_enhancement.rm_story.enhancement").refresh();
}
}
});
gModalForm.render();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:07 AM
Hi @Chetan Mahajan ,
Thank you for the script! While it didn't work in populating the Task Number in the Reference Field on a Story, it led me to discover a solution which was an enhancement to the UI Action Script on Enhancements:
CLIENT & LIST v2 COMPATIBLE = True
ONCLICK: openFormDialog()
SCRIPT:
function openFormDialog() {
var sysId;
if (typeof rowSysId == 'undefined')
sysId = gel('sys_uniqueValue').value;
else
sysId = rowSysId;
var gModalForm = new GlideModalForm('Create Story', 'rm_story');
gModalForm.setPreference('sysparm_view', 'scrum');
gModalForm.addParm('sysparm_query', 'short_description=' +
g_form.getValue('short_description').replace(/\^/g, '^^') +
'^description=' + g_form.getValue('description').replace(/\^/g, '^^') +
'^classification=Feature' +
'^u_reference_catalog_task=' + sysId +
'^sys_class_name=rm_story');
gModalForm.render();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 01:25 AM
to be honest, it's not really clear what your issue is. Instead of code, you should provide screenshots.
But what I can tell you: In a reference field, you will always see the value of the "display" field from the referenced record. So in case the table of the referenced record has set within the Dictionary the "display=true" option at the number field, then you will get that number in your reference field.
So this behavior is a fundamental one for the ServiceNow platform and not related to any UI Actions!
And unfortunately, there is no option to get anything else!
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 01:51 AM - edited 09-20-2023 01:52 AM
Hello @Josh Pirozzi ,
You can achieve it by getting the sys_id of the Parent Record in UI Action.
var story = new GlideRecord("rm_story");
story.short_description = current.short_description;
story.description = current.description;
story.priority = 4;
story.state = -5;
// Get the sys_id of the parent catalog task record.
var catalogTaskSysId = current.sys_id;
// Set the value of the parent record reference field on the Story Record.
story.setValue("rm_story.u_reference_catalog_task", catalogTaskSysId);
story.insert();
action.setRedirectURL(story);
You can modify the UI Action scripts for Ideas and Demands in a similar way.
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:07 AM
Hi @Chetan Mahajan ,
Thank you for the script! While it didn't work in populating the Task Number in the Reference Field on a Story, it led me to discover a solution which was an enhancement to the UI Action Script on Enhancements:
CLIENT & LIST v2 COMPATIBLE = True
ONCLICK: openFormDialog()
SCRIPT:
function openFormDialog() {
var sysId;
if (typeof rowSysId == 'undefined')
sysId = gel('sys_uniqueValue').value;
else
sysId = rowSysId;
var gModalForm = new GlideModalForm('Create Story', 'rm_story');
gModalForm.setPreference('sysparm_view', 'scrum');
gModalForm.addParm('sysparm_query', 'short_description=' +
g_form.getValue('short_description').replace(/\^/g, '^^') +
'^description=' + g_form.getValue('description').replace(/\^/g, '^^') +
'^classification=Feature' +
'^u_reference_catalog_task=' + sysId +
'^sys_class_name=rm_story');
gModalForm.render();
}