how to get the display value of a sys id being used in an array

sohan_snow
Tera Contributor

Hi All,

I need to get the assignment group of a catalog task on the description. The below scripts is working except for printing the Display value of the Grouip

grpp=[];

for(i=0;i<grpp.length;i++)
{
var gr= new GlideRecord('sc_task');
gr.request_item=current.sys_id;
gr.short_description='bingo fullillment group is : ' +grpp[i].getDisplayValue();                               //   Using grpp[i].getDisplayValue();   returns undefined
gr.description='bingo - description of this RITM';
gr.assignment_group=grpp[i];
gr.insert();
}

Catalog tasks are getting created as intended

find_real_file.png

Thanks in advance

1 ACCEPTED SOLUTION

okay, seems WF is not using ArrayUtil();



try this...



function retGrpName(val){




var gr = new GlideRecord('sys_user_group');  


gr.addQuery('sys_id',val);  


gr.query();  


while (gr.next()) {


      return gr.name;


}


},



gr.request_item=current.sys_id;


current.variables.dummy   = grpp[i];


gr.short_description='bingo fullillment group is : ' + retGrpName(grpp[i]);


View solution in original post

25 REPLIES 25

Harish KM
Kilo Patron
Kilo Patron

HarshTimes
Tera Guru

Hi Sohan


What is in your grpp array?it looks like the values in the array are not correct.


Hi Harsh,



The grpp array contains the sys id of the 4 returned group. I am inserting this group sys id in the assignment group of the catalog task consecutively and it is working fine.



However, I need to include the assignment group name in the short description of the catalog task which isnt happening.



find_real_file.png


Try this:



grpp=[];


var list = grpp[i].join(',');


var gr= new GlideRecord('sc_task');


gr.request_item=current.sys_id;


gr.short_description='bingo fullillment group is : ' + list.getDisplayValue();


gr.assignment_group=grpp[i];


gr.insert();


sohan_snow
Tera Contributor

Hi David,



thanks for your persistent help, the issue still persists



Workflow runscript (updated it as per the code provided by you)



var grpp=[];
var grp= new access007();
var grpp= grp.getgroup();


for(i=0;i<grpp.length;i++)
{
var list = grpp[i].join(',');



var gr= new GlideRecord('sc_task');


gr.request_item=current.sys_id;


gr.short_description='bingo fullillment group is : ' + list.getDisplayValue();


gr.assignment_group=grpp[i];


gr.insert();
}







Thanks in advance