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.

ACL to see own and watchlist incidents and incidents of groups he is memberof

Raviteja Kunal1
Tera Expert

Hi

I need to write ACL to read all the incidents of logged in user own incidents and if he is mentioned in watchlist and incidents of all groups he/she is memberof.

 

Thank You.

 
 
1 ACCEPTED SOLUTION

SunilKumar_P
Giga Sage

Hi @Raviteja Kunal1, can you try below in ACL script?

var userId = gs.getUserID();
var canUserAccess = [current.opened_by.toString(), current.opened_for.toString(), current.watch_list.toString()];
answer = canUserAccess .indexOf(userId) > -1 || gs.getUser().isMemberOf(current.assignment_group);

 

Regards,

Sunil

View solution in original post

3 REPLIES 3

SunilKumar_P
Giga Sage

Hi @Raviteja Kunal1, can you try below in ACL script?

var userId = gs.getUserID();
var canUserAccess = [current.opened_by.toString(), current.opened_for.toString(), current.watch_list.toString()];
answer = canUserAccess .indexOf(userId) > -1 || gs.getUser().isMemberOf(current.assignment_group);

 

Regards,

Sunil

Hi Sunil

Still I am able to see only own incident not group incidents

Sumanth16
Kilo Patron

HI @Raviteja Kunal1 ,

 

 

if (gs.getUser().isMemberOf(current.assignment_group) || current.watch_list.indexOf(gs.getUserID()) > -1) {

 

      answer = true;

 

} else if (current.u_group_watch_list.toString().length > 0) {

 

      var myGroups = getMyGroups().toArray();



      for (var i=0; i < myGroups.length; i++) {

 

              if (current.u_group_watch_list.toString().indexOf(myGroups[i]) > -1) {

 

                      answer = true;

 

                      break;

 

              }

 

      }

 

}

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda