How to restrict list view of records using ACLs

Singareddy Anil
Giga Contributor

Hi All,

 

i am using the below script to restrict users to access a module 

var hasPriv = getUserDiocese();
if ((hasPriv == true) && (gs.hasRole('admin') || gs.hasRole('itil'))) {
answer = true;
} else {
answer = false;
}
//This function gets the logged in users diocese
function getUserDiocese() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.query();
if (gr.next()) {
if (gr.company.getDisplayValue() == 'Parramatta') {
return true;
} else {
return false;
}
}
}

Can you please suggest me on this to restrict list of records on the module level 

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

You can create Read ACL to restrict who can see the record. Add the same script to it.


Please mark this response as correct or helpful if it assisted you with your question.

Hi,

 

Is it table level or field level.. Does my code require any changes

It is table level. Table.None. I dont think code requires change


Please mark this response as correct or helpful if it assisted you with your question.

Harsh Vardhan
Giga Patron

have you tried with query business rule?

 

kindly refer the thread below.

https://community.servicenow.com/community?id=community_question&sys_id=e844cb29dbd8dbc01dcaf3231f96...