Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hide incident records for users except assignment group members

lars7
Tera Guru

Hi

I want to hide records where a checkbox is set to true for all users unless they are member of the assigned assignment group

I want to do it with a business rule

1 ACCEPTED SOLUTION

lars7
Tera Guru

Solved the problem by making a before query BR. 

I simply made this script: current.addEncodedQuery("assignment_groupDYNAMICx^OR//FIELD//=false")

I did after doing a type of: 

Apparently using ^NQ in encoded query in a before query BR causes a bug when opening up incidents 

View solution in original post

10 REPLIES 10

I tried to follow the instructions from the second link you has provided.

My script is this: 

if(gs.getUser().isMemberOf(current.assignment_group))
current.addEncodedQuery("u_flagged=true");
else
current.addEncodedQuery("u_flagged=false");.

However, when I test it and put u_flagged=true in an incident, it disappears from the list even though I am a member of the incident's assignment group

Murthy Ch
Giga Sage

@lars

You can also do with before query bussiness rule:

Something like below:

current.addEncodedQuery("u_boolean_1=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^NQu_boolean_1=false"); //replace with your checkbox backend name

Let me know if any queries

(=tested)

Thanks,

Murthy

Thanks,
Murthy

I actually just did exactly do this.

It seems however it produces a bug or a conflict of some sort in San Diego. 

When that BR is active, every incident record I click on directs me to INC0000001 and sets all fields to read only.

Then, when I deactivate the BR and refresh the INC0000001 page, I am directed to the actual incident I clicked on in the first place. 

 

dhruvd
Tera Expert

Hi,

 

If you would like to do this with Business Rule then try the Before Query business rule.

 

A suggestion: For enhanced security on the platform it'll better to have ACls instead of query BR in the current scenario.

 

Thanks & Regards,

Dhruv 

lars7
Tera Guru

Solved the problem by making a before query BR. 

I simply made this script: current.addEncodedQuery("assignment_groupDYNAMICx^OR//FIELD//=false")

I did after doing a type of: 

Apparently using ^NQ in encoded query in a before query BR causes a bug when opening up incidents