HR Case Query Business Rule based on child HR Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 12:37 PM
I have a security requirement to restrict HR Cases according to a number of criteria such as roles and assignment groups. One of the other requirements involves allowing HR Case querying when the case has one or more task and the assignment group of the task is one of the assignment groups the user is a member of.
I envision the code looking something like this:
var caseNum = current.number;
var task = new GlideRecord('hr_task');
task.addQuery('parent', caseNum).addCondition('assignment_group', getMyGroups());
The problem with this is the table being queried by the business rule is the HR Case table. I understand the concept of querying the case table from a before query business rule but not how to query another table and have the result determine if the record should be shown or not. Would love some guidance on how to achieve this. Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 01:01 PM
To be clear,
- if a user is a member of Benefits and the HR Case is assigned to Benefits, you only want the Benefits team to see it?
- if a user is a member of Benefits and the HR Case is assigned to Benefits and the HR Task is assigned to Payroll, do you want both Benefits and Payroll to read it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 01:04 PM
Yes to both.
That way when Payroll is assigned the Task, they can view the associated HR Case for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 07:38 AM
I have come up with some code that seems to filter down to what I am looking for but when I impersonate a user and click on a case from the list, a "connection was reset" page is what appears. This is the code I have come up with so far:
var cases = [];
var query = 'assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744';
var task = new GlideRecord('hr_task');
task.addQuery('assignment_group', getMyGroups());
task.query();
while(task.next()) {
cases.push(task.parent + '');
}
query += cases.join('^ORsys_id=');
current.addEncodedQuery(query);