The CreatorCon Call for Content is officially open! Get started here.

Not to Show the roles in list collector that are already present in selected group

Preethi26
Tera Contributor

Hi Team,

I have created catalog request to add roles to groups.

Now, i want to not show the roles that are already in selected group.

Example if group Next gen already has itil role, so i should restrict it in list collector from user selection to avaoid redundant addition.

Kindly help

Preethi26_0-1701412574694.png

 

2 ACCEPTED SOLUTIONS

@Preethi26

then use this in advanced ref qualifier and add this in variable attributes

ref_qual_elements=group

I assume the roles variable refer to sys_user_role table

javascript: var query;
var arr = [];
var option = current.variables.action; // give correct action variable name here
var gr = new GlideRecord("sys_group_has_role");
gr.addQuery("group", current.variables.group); // give correct group variable name here
gr.query();
while (gr.next()) {
	arr.push(gr.getValue('role'));
}

if(option == 'add_role') // give correct choice value to compare
	query = 'sys_idNOT IN' + arr.toString();
else
	query = 'sys_idIN' + arr.toString();
query;

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

@Preethi26 

add this in variable attributes

ref_qual_elements=group;action

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

View solution in original post

13 REPLIES 13

@Ankur Bawiskar  Even after changing its shows the same.

As told i have called script include from both variables is this issue?

Preethi26_0-1701428717728.png

 

@Preethi26 

add this in variable attributes

ref_qual_elements=group;action

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

@Ankur Bawiskar Thanks Much for your time its working now.

@Preethi26 

Glad to help.

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