Help with a business rule on the HR Service table

Rob Sestito
Mega Sage

Hey Team,

I am trying to accomplish something through a business rule that was created for us.

The business rule originally is the following:

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

	// Add your code here
	if(!gs.getUser().isMemberOf('Employee Relations')) {
		current.addEncodedQuery('name!=Complex ER Case');
	}

})(current, previous);

I am trying to add one more group to this business rule. However, the things I have tried has not been working.

Here is what I have tried:

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

	// Add your code here
	if(!gs.getUser().isMemberOf('Employee Relations') || !gs.getUser().isMemberOf('Ask HR Team')) {
		current.addEncodedQuery('name!=Complex ER Case');
	}

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

	// Add your code here
	if(!gs.getUser().isMemberOf('Employee Relations') || ('Ask HR Team')) {
		current.addEncodedQuery('name!=Complex ER Case');
	}

})(current, previous);

Among a few others - but nothing seems to be working for me. I tried created a second business rule only for Ask HR Team to run in a different order, I tried a second IF statement within the original business rule, but unable to get it to work. I need to hide the service unless someone is a member of those two groups shown in the script.

Cheers,

-Rob

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

@TrevorK  & @jwalton -

I got it - the system for some odd reason does not like the name 'ask hr team'.

There is another group that myself and other admins are in which is HR Technology. I used that in a simple OR statement and it is working just right.

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

    if (!gs.getUser().isMemberOf('HR Technology') || (!gs.getUser().isMemberOf('Employee Relations'))) {

        current.addEncodedQuery('name!=Complex ER Case');

    }

})(current, previous);

Thank you both for responding and helping me out with this.

Cheers,

-Rob

View solution in original post

7 REPLIES 7

Jon23
Mega Sage

Hi,

Your code is checking if the user IS NOT a member of the groups.

Remove the '!' before the 'gs.' to check if they are a member of the groups.

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

	// Add your code here
	if(gs.getUser().isMemberOf('Employee Relations') || gs.getUser().isMemberOf('Ask HR Team')) {
		current.addEncodedQuery('name!=Complex ER Case');
	}

})(current, previous);

-> To help others, please mark this as Correct or Helpful if this response has been of any use. <-

Hey,

That did not work - I tried both ways with and without the '!' before 'gs' and a user in those groups could see the service and a person NOT in those groups could see it.

When it is just Employee Relations, and me as an admin is NOT in that group, the service is blocked from me. Which was why I thought it would / should be easy to just add in the same script using the OR function, and add one of the groups I am apart of.

And, I tried taking employee relations as the group out, and placed ask hr team by itself, and it is not working. So, maybe there is something about the ask hr team group/name the script does not like...?

But either way, when adding another group, it does not work and I can't see why.

Thank you,

-Rob

This is a Query business rule(?) so it will remove records from the list view where the name is NOT 'Complex ER Case'.  Is that what you are expecting.

Some of what you describe sounds more like ACL functionality as this will block accessing the record.  Did you check ACLs?

Can you provide additional information (screen shots)  of expected results and actual results?

This is a query BR, yes - this BR was created before my time here at the company. But, it was also created by a 3rd party consultant that helped implement HRSD, again before my time here.

I am trying myself to understand the motive behind this BR - and when I ask, the memory in full as to why is not there 100%.

For some reason, this 3rd party built this BR to hide the HR Service 'Complex ER Cases' on the hr service table. Why this would be created, I do not know. The only people in the backend able to modify the hr service on the service table are admins.

I checked ACLs and I see none that would do this as that was my first area to look when I noticed I could not get to the hr service on the service table.

So, from what I saw once I reached the BR, I added myself into the Employee Relations group and I was able to see the hr service on the service table. Seeing that I could see it once I was in the group, that made me try to add to the original statement to saying employee relations OR ask hr team.

All in all, it could be an issue with the name of ask hr team. I am just not sure - but strong feeling it is since I also tried replacing just the Employee Relations group and swapped in the Ask HR Team group and I could not see the service again.

Thanks,

-Rob