How to filter users for Activity Stream @mention

Community Alums
Not applicable

How to filter users for Activity Stream @mention, we want to hide admin accounts when user mention @.

5 REPLIES 5

Elijah Aromola
Mega Sage

Can you provide more details? What do you mean by hide? Just remove them from the list? 

Community Alums
Not applicable

when user seached in work notes by using @mentions then he shouldn't see admin accounts.

Bryan Cole2
Giga Contributor

I too have been looking for an answer to this problem. All active users appear to be retrieved, and we have a need to omit any users that are not tied to the current user's company.

Bryan Cole2
Giga Contributor

I found the answer! Inspired by the post here: https://community.servicenow.com/community?id=community_question&sys_id=6cec4b29db9cdbc01dcaf3231f96...

I created a Before Query business rule on the sys_user table the below logic. It will only trigger if the query is coming from an @mention:

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

    var query = 'active=true^roles!=admin'; //filter out admin users in @mention

    try {
        if (gs.action.getGlideURI().toString().startsWith('api/now/form/mention/record/')) {
            current.addEncodedQuery(query);
        }
    } catch (err) {
        gs.log("@mention Filter Runtime Error: " + err);
    }


})(current, previous);

This will show all users who are not an admin, including users without a role, so the query string may need to be refined more for your specific needs.