kristenankeny
Tera Guru

I've been able to get a filter to work in part with the following update to the new AllFilterService. However, I have two remaining issues:

- On initial load, if the user's default tab is the "All", it returns no results. They have to click to pinned or my and back to all to view the results. Any tips on getting the filter to run on load correctly?

- Once you click into a schedule, you're taken to the $oc_workbench, there is a drop down near the top of the page to select another group. I need to apply a filter here as well. However, I don't see us having access to this UI page. How can I limit the options on the workbench drop down?

 

angular.module("sn.on_call.now.groups").service("AllFilterService",[function(){
	var allFilterService = this;
	var _all = [];
	var _groups = [];
	
	allFilterService.getFilteredGroups = function(groups, activeUserID){
		if(!groups || groups.length < 1 || !activeUserID){
			_all = [];
			_groups = [];
		}
		else if(_groups.length !== groups.length){
			_groups = groups.concat(_groups);
			var allowedGroups = [];
			groups.filter(function(group){
				
				var requestBody = ""; 

				var client = new XMLHttpRequest();
				client.open("get","https://dev82038.service-now.com/api/now/table/sys_user_group?sysparm_query=sys_id%3D"+group.sys_id+"&sysparm_fields=type&sysparm_limit=1");
				client.setRequestHeader('Accept','application/json');
				client.setRequestHeader('Content-Type','application/json');
				client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'Th0m4s195!'));
				client.onreadystatechange = function() { 
					if(this.readyState == this.DONE) {
						//document.getElementById("response").innerHTML=this.status + this.response; 
						var grType = this.response;
						if(grType.indexOf('74af88c6c611227d0066386e74dc853d') > -1){
							allowedGroups.push(group);
						}
					}
				}; 
				client.send(requestBody);
			});
			_all = allowedGroups;
		}
		return _all;
	};
}]);

kristenankeny
Tera Guru

I changed methods completely to solve the filtering issue for $oc_groups. Adding a before query business rule against cmn_rota seems to fix that UI page and will only show my users what I want them to see (there are five on call schedules, this user only sees two from "all on-call schedules").

find_real_file.png

 

However, this fix does not work on the $oc_workbench "groups" drop down:

find_real_file.png

 

Has anyone had success filtering this drop down menu?

kristenankeny
Tera Guru

After putting the before query business rule in our company dev instance, we found that it is being applied both in the $oc_groups and $oc_workbench and $oc pages in all areas where they can change the on-call schedule that they are looking at. 

View solution in original post

Hi Kristen, 

I have questions about On-Call Scheduling and you seem like a person who might have the answer.

 

I've a bunch of data to import for shifts and schedules, so I'm trying using import sets.

 

Questions :

1. Is it possible to use import set for this module, as so many things are inter-related here, and every entry has schedule and schedule entries.

2. I cannot find this fields "Allow Shift Schedule overlap" "Escalation rule on Shift overlap" anywhere in tables, which are present on create on-call schedule wizard.

Please respond at earliest.

 

Regards,

Laukik.

Hi Kristen, Can you please share the before query business rule snippet through which you were able to do this change?