Hiding HR Services from Section

Rob Sestito
Mega Sage

Hey SN Comm!

I want to try something I believe is doable through client script but need some help with it.

I have 3 HR Services that are specific to Employee Relations Cases

  1. ER Report
  2. ER Administrative
  3. ER Union Grievance

Both 2 and 3, need to be available ONLY when someone within the Employee Relations Group is in the system creating their own Cases. Other than that, ER Report can be available all the time.

I was thinking of an onLoad client script (would need to be hitting the Case Creation Page), to only show ER Report when the user creating a new HR Case IS NOT in Employee Relations Assignment Group (or tie it to a role if need be).

Anyone able to work this out with me on how I could get this done? And, if i could do something other than client script?

Thanks to all in advance,

~Rob

1 ACCEPTED SOLUTION

So the real pain I encountered was, this is a UI page. Even if you modify the reference qualifiers , you will only get it to work on a FORM, not on a UI page. 

Achieved it using the Query Business rule on HR services table.

Assign a role to the specific users you want, in my example the role name is "XYZ".

 

find_real_file.png

Below is the script

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

	// Add your code here
	if(!gs.hasRole("XYZ"))//If the user doesnt have an XYZ role then exclude below HR Services
	current.addEncodedQuery("name!=ER Administrative^name!=ER Union Grievance");

})(current, previous);

View solution in original post

16 REPLIES 16

Hey Aman,

So I used your BR option - and while it worked, it also hid those two hr services from a user that has the role I gave. Here below are the details to show you -

The Role I used, which is given to all users within the Employee Relations Assignment Group:

find_real_file.png

Here is the BR:

find_real_file.png

find_real_file.png

 

I impersonated someone within another group (that does not have this role) and only ER Report showed - great!

Impersonated a user within the ER Group - only ER Report showed up.

Not sure what is missing here since you stated it worked for you.

Thank you!

~Rob

The event name in the BR should be sn_hr_core.er_writer

Please try that and let me know if it worked. 

Interesting - that was how I first had it, and it did not show that it was working for me. Which made me change it to what I showed you.

Overall, this has worked exactly how I wanted/needed it!

Thank you sir!!!

~Rob

Good to hear that its working. 

Thank you,

-Aman Gurram

_ _ _ _
ServiceNow Employee
ServiceNow Employee

You can achieve this using the HR Criteria field on the HR Service to only show the Services for users in a certain group.

Example HR Condition on an HR Criteria:

find_real_file.png

 

Documentation for HR Criteria

 

If this comment was helpful or correct, please mark it as such.