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.

Users can only see users with the same email domain

Servinho Deve
Tera Contributor

Hello everyone!
I need to add logic to the Users table, so non-admin users can only see users with the same email domain

e.g:

user@example.com should only be able to see users that end in @Example.com

and otheruser@test.com can only see users that end in @test.com

 

Any idea? Thanks.

1 ACCEPTED SOLUTION

Sarika S Nair1
Kilo Sage

Hi @Servinho Deve 

create one advanced read ACL like below in user table.

 

var userEmail = gs.getUser().getEmail();
var domainIndex=userEmail.indexOf("@");
var emailDomain=userEmail.slice(domainIndex+1,userEmail.length());
if(current.email.indexOf(emailDomain)>=0){
answer = true;
}
else{
answer = false;
}

 

 

View solution in original post

1 REPLY 1

Sarika S Nair1
Kilo Sage

Hi @Servinho Deve 

create one advanced read ACL like below in user table.

 

var userEmail = gs.getUser().getEmail();
var domainIndex=userEmail.indexOf("@");
var emailDomain=userEmail.slice(domainIndex+1,userEmail.length());
if(current.email.indexOf(emailDomain)>=0){
answer = true;
}
else{
answer = false;
}