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

Chuck Tomasi
Tera Patron

Hi Tony,



This part has be a bit confused.



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


Did you mean a related list entry to associate the story with the current incident? A related link is a place for UI actions.


Sorry for the confusion



On an individual incident I added an option "create story" to the hamburger menu, the code I posted executes when this option is selected and the story is successfully created.



The option to add a story appears in the related links section of an incident which is good, but I would also like any story that gets created via the link in the hamburger menu to appear in the related links section for the incident in question.




I tried Kalai suggestion but that does not appear to work.


Hi Tony,



A screenshot would be most helpful here for what you are trying to accomplish. I'm not quite understanding and it may be semantics at this point.



As noted before Related links are a listing of Form Link UI Actions. It's not a place to list records related to the current incident (or any other record.) Those would be listed in a Related List (tables at the bottom of the form.)


Inside of an incident when a user selects Create Story



Hamburger.PNG



A screen to create a new story appears



NewStory.PNG




Once the user returns to the incident screen I would like the related list for the incident to show the new story


relatedlinks.PNG