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

adityaghosh
Tera Guru

Are you using this in a WF Script ? If yes, then the following logic will work



create a dummy custom.variables e.g. custom.variables.dummy



Make sure grpp[i] has value in it first...



e.g:-



gr.request_item=current.sys_id;


custom.variables.dummy   = grpp[i];


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


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


Hi Shiladitya,



Thanks for your help. I tried with the code but got the below error. should I be defining "custom" somewhere something like var custom=''; or var customer=[];



find_real_file.png


Using that script: just


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


Hi Sharique,



thanks a ton for your patience, I have pasted the update code and log sceenshot on the below conversation of Shiladitya. Can you please take a look


Meanwhile, I am also trying with your previous code where   you gave updated both workflow script and script include


Sorry typo mistake..



Instead of custom use current



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