If I use a Before Query business rule will it cause performance issue

Akshay Pundeer
Tera Contributor

If I use a Before Query Business Rule and my system has 230,890 records in the HR case table, will it cause an issue?

I'm not using ACLs because there are too many on the HR table and its parent table, making it time-consuming and leading to conflicts.

 

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

    var globalMobilityGroup = '0cd7b8d31b3204144b9e433fbd4bcb21';
    var allowedServices = [
        'd31f18171b3ec0144b9e433fbd4bcb71',
        '2723c6ae1bb594104b9e433fbd4bcbd3',
        '65347bc91b23f700f96c0dc2cd4bcb6b'
    ];

    if (!gs.getUser().isMemberOf(globalMobilityGroup)) {
        current.addQuery('hr_service', 'NOT IN', allowedServices.join(','));
    } else {
        var query = current.addQuery('assignment_group', globalMobilityGroup);
        query.addOrCondition('hr_service', allowedServices[0]);
        query.addOrCondition('hr_service', allowedServices[1]);
        query.addOrCondition('hr_service', allowedServices[2]);
    }

})(current, previous);
7 REPLIES 7

Mark Manders
Mega Patron

What version are you on? The Deny-Unless ACL was introduced with Xanadu and will save you a lot of time with a requirement like this.

A before query will work, but it will have to run through the entire table. With a deny unless ACL you can just easily set the conditions.
Add the role needed to read at all, add the data conditions of hr service = abc or def or ghi and assignment group = mobility group and a security attribute of group = mobility group (ensuring the user is member of that group.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Akshay Pundeer
Tera Contributor

Washington Version

If you can wait for a bit, I would really use the Deny-Unless ACL once you upgrade to Yokohama. It will be a way easier solution. And with Washington becoming unsupported in May, it's around the corner.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@Akshay Pundeer 

why not use HR COE security policy and it will handle the restriction for respective HR Services?

Create a COE security policy 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader