Reference Qualifier for assignment group depending on Assigned to field.

LakshmiNarayan7
Mega Guru

Reference Qualifier for assignment group depending on Assigned to field.

After choosing the Assigned To field, the Assignment Group should show only the group of assigned to user.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Lakshmi,

you are sending assigned_to value as parameter to the function from the ref qualifier but as per the function declaration it doesn't accept any parameter

so make these changes

1) make the function accept parameter 

2) remove line number 7

3) in line number 9 use below; don't put quotes around the variable

gr.addQuery('user', a);

4) also use while instead of if in line number 11

5) while returning the array use join method

updated script

assignmentGroup: function(a){

var arryVal = [];

var gr = new GlideRecord('sys_user_grmember');

gr.addQuery('user',a);

gr.query();

while(gr.next()){

arryVal.push(gr.group.toString());

}

return 'sys_idIN' + arryVal.join(',');

},

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Lakshmi,

you are sending assigned_to value as parameter to the function from the ref qualifier but as per the function declaration it doesn't accept any parameter

so make these changes

1) make the function accept parameter 

2) remove line number 7

3) in line number 9 use below; don't put quotes around the variable

gr.addQuery('user', a);

4) also use while instead of if in line number 11

5) while returning the array use join method

updated script

assignmentGroup: function(a){

var arryVal = [];

var gr = new GlideRecord('sys_user_grmember');

gr.addQuery('user',a);

gr.query();

while(gr.next()){

arryVal.push(gr.group.toString());

}

return 'sys_idIN' + arryVal.join(',');

},

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

https://docs.servicenow.com/bundle/newyork-platform-administration/page/script/server-scripting/task...

 

This is what servicenow provides. Twick it.

 

Thanks,
Ashutosh Munot

Hi,

If you got your answer close this thread.

Thanks,
Ashutosh

Sanket Khabiya
Kilo Sage

Hi Lakshmin Narayanan,

I have removed many flaws which were in your scripts. Please try below script.

 

Script Include Name : refQuInci
API Name : global.refQuInci                   

function refQuInci(a){
var arrayVal = [];

var gp = new GlideRecord('sys_user_grmember');
gp.addEncodedQuery('user='+a);
//gs.addInfoMessage(gp.getEncodedQuery());
gp.query();
while(gp.next())
{
array.push(gp.getValue("group"));

}
gs.addInfoMessage(array.toString());
return 'sys_idIN' +array;
}

 

Add this reference qualifier to the Assignment Group field
Reference qualifier :

javascript:global.refQuInci(current.assigned_to);

 

Regards,

Sanket