Override global before query business Rule on subject_person field

Aidy Burrow
Tera Contributor

There is a global business rule (user query) which filters out inactive users on the sys_user table using current.addActiveQuery(); for non admins.

One of our HR services is to raise a case for leavers (within the past 12 months), however there is no way to populate these users in the subject_person field (which is a reference field to the sys_user table) within a HR case as any reference qualifier is always suffixed with active=true, filtering out the users needed for selection. 

This also is an issue with passing the user from a record producer variable - the inserted record's subject_person is empty.

We want to avoid touching the global BR as we only want it to be skipped/bypassed for one particular HR service.

Does anyone else have HR services covering inactive users and is there a way around this?

1 ACCEPTED SOLUTION

Hi,

Best of luck, haha!

If my reply ends up guiding you Correctly, please also mark it as Correct.

Take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

8 REPLIES 8

Susan Britt
Mega Sage
Mega Sage

Hi Aidy,

 

Yes, we have had to do so quite a few times for customers and different business requirements. You can modify the OOB (I'd copy the OOB one to modify it, then just deactivate the OOB version) code to meet your needs.  

Below is one example.

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

	var url = GlideTransaction.get().getRequest().getHeader("referer");
	
	//If not redirected from the XXXX record producer and not admin nor hr agent - only see active users
	if ((url.indexOf('<insert sys_id of record producer that should allow inactive users to be seen>') < 0) { 
		if (!gs.hasRole("admin") && (!gs.hasRole("hr_basic")) { 
			current.addQuery("active", "true");
		}
	} 
//Else, it is from the XXXX record producer, so users can see active and inactive users, regardless of current user's role	

})(current, previous);

I'd considered this as a possible solution, but the Global BRs are under the control of the overall platform team and there will be mountains of red tape to cut through to get this changed.

It's a genuine solution as does exactly what we need, so thank you for your quick response - I've tested this and it works perfectly.

I was hoping there would be a way to avoid any overlap between HRSD and ITSM, but alas, there probably isn't.

Thanks again,

Aidy

 

John Zhang1
Kilo Patron
Kilo Patron

You can only select an active user in Subject Person field of HR case form because of its reference qualifier configuration like below. not due to user table "user query" BR.

find_real_file.png

A way around is to create one custom field such as: Nonactive Subject Person field, which only display all nonactive users.    This field can be displayed for one particular HR service.  When this field is displayed, you can hide OOB Subject Person field, otherwise you can hide the Nonactive Subject Person field when OOB Subject Person field is required.

find_real_file.png

 

If my reply is Helpful/Correct, please mark the answer as Helpful/Correct.  

 

 

 

 

Unfortunately the BR overrides any reference qualifier - I have a dictionary override on this field, however the BR concatenates my query with active=true, which I validated this through debugging.

Whatever reference qualifier I used (whether in the dictionary or script include function), the encoded query that was actually being executed was always suffixed with active=true.