UI Action/Business Rule to Auto Create a Story form a specific sc_task item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 02:17 PM
I am trying to build a UI action/Business rule to Create an Agile Story when a Catalog request is submitted for a ServiceNow Enhancement. I wanted to copy the OOTB Create Problem UI action /Business rule. Coding isn't something I do so i'm having a hard time finding the right codes to replace Incident and problem in the OOTB script. I would aslo like them to create a parent child relationship and added to related lists for both sc_task and story.
I created a catalog item with a custom workflow that creates a sc_task and assigns it to the group that would work the ticket.
Based on the SC Task Short description it should auto create story based on parameters from that sc_task. Below are the scripts i've been working with.
- UI Action Script -
Condition:
current.task_state != TaskState.CLOSED && current.Story_id.nil()
Script:
var story = new TaskUtils().getStoryFromTask(current);
if(story != undefined) {
current.story_id = story.insert();
var mySysID = current.update();
gs.addInfoMessage(gs.getMessage("Story {0} created", story.number));
action.setRedirectURL(story);
action.setReturnURL(current);
} else {
action.setRedirectURL(current);
}
- Business Rule Script -
** I know this is wrong as it should dot walk to current variables and then the name since all the data on the sc_task item is on the variables.
(function executeRule(current, previous /*null when async*/) {
var story = new GlideRecord("Catalog Task");
story.short_description = current.short_description;
story.description = current.description;
story.product = current.product;
story.theme = current.theme;
story.priority = current.priority;
story.company = current.company;
story.sys_domain = current.sys_domain;
var sysID = story.insert();
current.story_id = sysID;
var mySysID = current.update();
gs.addInfoMessage("Story " + story.number + " created for SNOW Enhancement task");
action.setRedirectURL(current);
})(current, previous);
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2019 08:42 AM
Please see reply to you're previous comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 07:53 AM
Did you get this to work, I am trying to do the same thing? Would you be willing to share your final solution?