How to filter in reference qualifier to display group for specific value

Natalia34
Tera Expert

Hi all,

In Resource Plan module, I would like to display Groups in lookup list that tag to certain country(for eg : Malaysia) to be display in the list. I have created choice list field country in Group table (sys_user_group) so that I will able to filter that in the list. Kindly, please help.

Current filter for the Groups is as below:

find_real_file.png

Thanks and Regards,

Natalia

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi,

So is the current ref qualifier OOB and you wish to add one more condition to it?

if yes then do this; ensure you give correct choice value for country

javascript: 'Existing Condition' + '^u_country=Malaysia';

Regards
Ankur

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

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron

Hi,

So is the current ref qualifier OOB and you wish to add one more condition to it?

if yes then do this; ensure you give correct choice value for country

javascript: 'Existing Condition' + '^u_country=Malaysia';

Regards
Ankur

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

Hi Ankur,

I have tried this and it works fine. Thank you so much.

Thanks and Regards,

Natalia

@Natalia 

Glad to help.

Please mark response helpful as well.

Regards
Ankur

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

Adrian Ubeda
Mega Sage

Hi Natalia,

This it's an OOTB script include, if you want add that condition you should edit it as follows:

ResourcePlanReferenceQual.getGroupReferenceQual = function(current) {
	var groupsMatchingUser = [];
	if(JSUtil.notNil(current.user_resource) && current.resource_type == 'user') {
		var rmUser = new ResourceManagementUser(current.user_resource);
		groupsMatchingUser = rmUser.getResourceGroups();
		return 'sys_idIN'+groupsMatchingUser.join(',')+ '^u_field=' + fieldValue;
	}
	
	else if(JSUtil.notNil(current.role) && current.resource_type == 'role') {
		var groupsMatchingRole = [];
		groupsMatchingRole = ResourceGroupRoles.groupsHavingRole(current.role);
		return 'sys_idIN'+groupsMatchingRole.join(',')+ '^u_field=' + fieldValue;
	}
	return 'roles=pps_resource^active=true^u_field=' + fieldValue;
};

If you need another kind of query add it at the end of each return where '^u_field=' is.

If it was helpful, please give positive feedback.
Thanks,

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆