how can we grant watchlist users on an HR Case the ability to see all HR Tasks linked to it

DASAMANDAMS
Tera Contributor

Hi team , i have a requirement to grant watchlist users on an HR Case the ability to see all HR Tasks linked to it

 

i tried with acl 

 

but it is not working

 

but can someone assist me on this

 

(function() {
    var userID = gs.getUserID();

 

    // Get the parent HR Case record
    var hrCase = new GlideRecord('sn_hr_core_case');
    if (current.parent && hrCase.get(current.parent)) {

 

        // Check if user is in the HR Case watchlist
        var watchlist = hrCase.watch_list.toString().split(',');
        if (watchlist.indexOf(userID) !== -1) {
            return true; // Allow access
        }
    }

 

    return false; // Deny access
})();

3 REPLIES 3

Mark Manders
Mega Patron

They will need to have the roles to see HR case tasks. Since tasks are usually meant to resolve the Case, tasks are only visible to fulfillers. But I can't look at your ACLs to see if anything is preventing them, nor have you shared what kind of users are on the watchlist of the case.


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

Hi @Mark Manders 

I have Seen other ACLs out of box on the hr_task table, users without even the fulfiller role are able to see the task if they are added to the watchlist field.

 

We require the same functionality: if users are added to the watchlist on the HR Case, they should be able to see all HR Tasks linked to that case

Shraddha Kadam
Mega Sage

Hello @DASAMANDAMS ,

 

Please create before query business rule on the HR Task table and write below script -

 

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

    if (gs.hasRole('admin') || gs.hasRole('sn_hr_core.admin')) {
        return; // Allows users with these roles to view all HR Tasks without restriction.
    } else {
        // parent.watchlist is dynamic me
        current.addEncodedQuery('parent.watch_listDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
    }
})(current, previous);
If my response was helpful, please mark it as correct and helpful.
Thank you.