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

Hi


thanks for your help, still the group display value came to be undefined




update workflow script code



var grp= new access007();
var grpp='';
var grpp= grp.getgroup();
gs.log('yes, the group returned is = '+grpp.getDisplayValue());
gs.log('yes, the group length is ='+grpp);


for(i=0;i<grpp.length;i++)
{


var gr= new GlideRecord('sc_task');
gr.request_item=current.sys_id;
current.variables.dummy = grpp[i];
gr.short_description='bingo fullillment group is : ' +current.variables.dummy.getDisplayValue();


//gr.short_description='bingo fullillment group is : ' +grpp[i].getDisplayValue();
gr.description='bingo - description of this RITM';
gr.assignment_group=grpp[i];
gr.insert();
gs.log('yes, the group display name is :'+grpp[i].name );
}







find_real_file.png


I doubt the array has any values.



please try the following to check values in the array



gr.request_item=current.sys_id;


current.variables.dummy   = grpp[i];


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


//gr.short_description='bingo fullillment group is : ' +current.variables.dummy.getDisplayValue();


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


hi shiladitya,



the array has the sys id of the group stored, please find the below screenshot



find_real_file.png


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]);


Hi Shiladitya, thanks a ton for your persistent help, finally ....


must say you got a never say die spirit... you dint leave it until it was resolved