Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Users can able to see their parent group or nested group tickets only

sd khaja
Tera Contributor

we have categories and their assignment groups like 

1. Hardware - (Hardware group)

2. Software - (Software group)

3. Resource - (Resource group)

4. Inquiry- (Inquiry group)

 

every parent group has nested groups of up to 20+ 

if the logged-in user is a member of the Hardware group or any of its child groups, he can only see tickets which 

'Category' = "Hardware"

 

if the logged-in user is a member of the Software group or any of its child groups, he can only see tickets which 

'Category' = Software"

1 REPLY 1

Not applicable

Hello @sd khaja ,

Create before query business rule on incident table and write the below script.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var arr=[];
	var grmem=new GlideRecord('sys_user_group');
	grmem.addQuery('parent','software group sys_id');
	grmem.query();
	while(grmem.next())
		{
			arr.push(grmem.getValue('name'));
		}
	if(gs.getUser().isMemberOf('software group name')) 
		{
			for(var i=0;i<arr.length;i++)
				{
					if(gs.getUser().isMemberOf(arr[i]))
						{
							current.addQuery('category','software');
						}
				}
		}

})(current, previous);

 

Please mark my answer as correct and helpful if it helps you.

Regards,

Namrata