How to restrict a specific group incidents to only its group members and to caller servicenow

Sanjay Kumar10
Tera Expert

I would like to restrict a specific group incidents to only its group members and to caller servicenow. I tried below script and I can able to see incidents when I'm part of a specific group but for caller I cannot able to see incident.

It's working for specific group members but not to caller. Please someone help me.

 

SanjayKumar10_0-1726731188130.png

 

@Dr Atul G- LNG 

 

3 REPLIES 3

Robbie
Kilo Patron
Kilo Patron

Hi @Sanjay Kumar10,

 

I believe this is a snippet from a 'Query' Business Rule - correct? Please confirm. If so, this is the approach I would also take and will provide the functionality you require.

What I am not able to see an .addOrCondition for the caller_id field?

 

Can you provide the full code and the screen shot does not show everything.

 

I would expect something similar to the below as well as your existing group check logic:

 

// in addition to your current group log check

var userID = gs.getUserID(); // variable to store current logged in user
.addOrCondition("caller_id", userID)

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

Hello Robbie,

 

Yes, It's a before query business rule. Sure below is the code.

Under Condition field, I kept below condition

 

!gs.getUser().isMemberOf('b39adf721bb63010ee5a8408624bcb89') || gs.getUserID()!= current.caller_id.getValue()

 

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

var grp = current.addNullQuery('assignment_group').addOrCondition('assignment_group','!=','b39adf721bb63010ee5a8408624bcb89');

})(current, previous);

Hi @Sanjay Kumar10,

 

Have you tried adding the .addOrCondition to your query business rule (not forgetting to also add the variable for the userID) as per my response?

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie