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

Display Value of a reference field in a UI action is not working

Sandy7
Tera Expert

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();
}

1 ACCEPTED SOLUTION

Replace 

kbshort_description += gr.release.getDisplayValue();

with


if(kbshort_description.indexOf(gr.release.getDisplayValue()) == -1)
    kbshort_description += gr.release.getDisplayValue();

View solution in original post

7 REPLIES 7

Replace 

kbshort_description += gr.release.getDisplayValue();

with


if(kbshort_description.indexOf(gr.release.getDisplayValue()) == -1)
    kbshort_description += gr.release.getDisplayValue();

Thank you! Perfect!  I appreciate your help!

Sorry...I didn't realize that this UI Action was Client side enabled...


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!