The CreatorCon Call for Content is officially open! Get started here.

How do I add a related link for an incident using code in a UI action

Tony Santos1
Tera Contributor

I created a UI action that allows for the ability add a story from an individual incident the code is as follows

var story = new GlideRecord("rm_story");

story.short_description = current.number + " - " + current.short_description;

story.description = current.short_description;

var sysID = story.insert();

action.setRedirectURL(story);

action.setReturnURL(current)

How can I adjust to code to ensure a the new story also gets added as a related link in the incident in question?

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

var story = new GlideRecord("rm_story");


story.short_description = current.number + " - " + current.short_description;


story.description = current.short_description;


story.parent=current.sys_id;


var sysID = story.insert();


action.setRedirectURL(story);


action.setReturnURL(current)


View solution in original post

8 REPLIES 8

If the story is getting created without any issues, then adding the single line change stated above should work.


Kalai,



  You are correct thank you. For some reason this doesn't work in my own personal instance from the developer site, but it works when I tried it in my own companies dev environment, thanks for your help.


Do you mean that you'd like to see these related stories to appear against the incident, much like child incidents, related problems, changes, etc?



Do you have a field in your [rm_story] table that relates to the incident?


Kalaiarasan Pus
Giga Sage

var story = new GlideRecord("rm_story");


story.short_description = current.number + " - " + current.short_description;


story.description = current.short_description;


story.parent=current.sys_id;


var sysID = story.insert();


action.setRedirectURL(story);


action.setReturnURL(current)