- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 06:16 AM
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
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 11:52 AM
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]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 08:57 AM
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;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 09:33 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 11:41 AM
Hi Sharique,
could you elaborate regarding
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 01:22 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 11:14 PM
thank you so much for your continuous help