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

ok, try the below in your script include and stick with your original workflow run script!



getgroup:function(){


 


  var getid=[];



var gr= new GlideRecord('u_007_access');


      gr.addQuery('u_catalog_item_name',current.variables.name);


gr.query();


while(gr.next())


 


  {


    getid.push('gr.u_group007');


   


  }


  var eachId1 = getid.split(',');


 


return eachId1;



},


Hi David/Sohan,



<I updated the code>



Unless you pass the right informations, then how would you retrieve data?


I am using redesigning the script(which   was already available):



in the workflow script:



var scr= new access007().getgroup(current.variables.name);



var grp= scr.sys;


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


var gr= new GlideRecord('sc_task'); /


gr.initialize(); //everybody forgot that


gr.request_item=current.sys_id;


gr.short_description='bingo fullillment group is : ' + scr.name;


gr.assignment_group=grp[i];


gr.insert();
}



Script Include(should not be client callable though, but this too should work):


getgroup:function(var_val){


  var getid={};// ill create   object here



var gr= new GlideRecord('u_007_access');


gr.addQuery('u_catalog_item_name',var_val;


gr.query();


while(gr.next())



  {


    getid.sys=gr.getValue('u_group007')); // you want to send the group sys_id here


    getid.name=gr.getValue('abc')); // you want to send the group name here


  }



var data= JSON.stringify(getid);


return data;


Hi Sharique,



could you elaborate regarding



find_real_file.png



I understand that we need to get the display name of the group in getid.name. not sure what 'abc' would refer to in my case. please find the below screenshot from the table 'u_group007'.



can something like gr,getDisplayBox('u_group007').value will work, I understand this will work in client script but do we have a server glide script to get the display name of the group





find_real_file.png


Hi,


The approach becomes even simpler then. Change it to


getid.sys=gr.getValue('u_group007')); // you want to send the group sys_id here


  getid.name=gr.getDisplayValue('u_group007') ; // you want to send the group name here


thank you so much for your continuous help