- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 08:59 AM
Hello,
I have a UI action creating a knowledge article from a List View (so, you select 1 or multiple boxes on the list list view, and then there's the menu option to create a knowledge article).
I want the knowledge article short description to include the Release (release is reference field) from the list view. It is currently returning the sys id of the Release field.
I have tried to add
This is the code I have in the UI action: The line that is bold and italics is the line that populates the short description of the KB.
If I leave as is, it will return the sys id. If I put gr.release.getDisplayValue(); it does nothing at all - no article is created.
Any ideas? Thank you!
function runFunction()
{
var val = g_list.getChecked();
//alert(val);
var kbtext = '';
var kbshort_description = '';
var gr = new GlideRecord('rm_story');
gr.addQuery('sys_id','IN',val.toString());
gr.query();
while(gr.next())
{
kbshort_description = 'Stories deployed in ' + gr.release;
kbtext = kbtext+ 'Number: '+gr.number+'<br /> Short Description: '+gr.short_description +'<br/><hr/>';
// alert(kbtext);
}
var kbart = new GlideRecord('kb_knowledge');
kbart.initialize();
kbart.short_description = kbshort_description;
kbart.text = kbtext;
kbart.insert();
alert('KB article is created');
g_list.refresh();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 11:29 AM
Replace
kbshort_description += gr.release.getDisplayValue();
with
if(kbshort_description.indexOf(gr.release.getDisplayValue()) == -1)
kbshort_description += gr.release.getDisplayValue();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 12:51 PM
Hi,
Please try:
kbshort_description = 'Stories deployed in ' + gr.release.getDisplayValue();
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 12:53 PM
Hi - thanks, I tried that several times and it will not work. It doesn't create any knowledge article.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 07:03 PM
You cannot user server side functionalities in the client side UI action. You need to use server calls using a glideajax
Here is the UI action script
function runFunction() {
var gajax = new GlideAjax("CreateKB");
gajax.addParam("sysparm_name", 'createkb_from_story');
gajax.addParam("sysparm_storyId", g_list.getChecked());
gajax.getXMLAnswer(addKB);
}
function addKB(){
location.reload();
}
Script Include:
Name:CreateKB
Client callable: TRUE
var CreateKB = Class.create();
CreateKB.prototype = Object.extendsObject(AbstractAjaxProcessor, {
createkb_from_story: function(){
var surveyId = this.getParameter('sysparm_storyId');
var kbtext = '';
var kbshort_description = '';
var gr = new GlideRecord('rm_story');
gr.addQuery('sys_id','IN', surveyId);
gr.query();
while(gr.next())
{
kbshort_description += gr.release.getDisplayValue();
kbtext = kbtext+ 'Number: '+gr.number+'<br /> Short Description: '+gr.short_description +'<br/><hr/>';
}
var kbart = new GlideRecord('kb_knowledge');
kbart.initialize();
kbart.short_description = 'Stories deployed in ' + kbshort_description;
kbart.text = kbtext;
kbart.insert();
},
type: 'CreateKB'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 10:55 AM
Hi, this works GREAT!
Now, the only thing I am missing is that in the short description of the knowledge article, it's repeating the release i... so if I select 3 stories (which have the same value in the Release column), it's repeating the short description 3 times.
Any idea how to get it to just look at only 1 of the stories selected & return the value from the release field, since all items selected will have the same value in release.
thanks!!!