Restrict @mention suggestion to Requested by/Requested for, watclist and fulfillers only

Vee Jay Recana
Mega Guru

Hello Everyone,

 

We are currently utilizing the @mention and our client wants to limit the suggestions to Requested by/Requested for, watchlist, and fulfillers(assigned to) only. I based my business rule script on this discussion.
Is there any way to achieve it? 

Thank you

 

VeeJayRecana_0-1680180373206.png

 

Business Rule: Before Query
Script:

(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);
4 REPLIES 4

Community Alums
Not applicable

HI @Vee Jay Recana ,

In the current platform there is no out-of-the-box supported way to change the behavior of the @mention feature. It is not possible to:

1 - Not return users who can not see the record
2 - Limit the @mention feature to certain roles (e.g. only users with the itil role)
3 - Disable the @mention feature

It is possible to implement a customization to disable the @mention feature, or restrict it to certain roles, based on a workaround described in this Community article:
https://community.servicenow.com/community?id=community_question&sys_id=1bf50761db1cdbc01dcaf3231f96...

 

Hi @Community Alums , thank you for your quick response. I just have one small question. Is it possible to use addEncodedQuery to filter the users from Requested By/For, watchlists, and fulfillers? I was trying it on my PDI but I can't get the correct syntax. 

One clarification to the response above. You mentioned It is not possible to #3 disable the @mention feature. We disabled it in our instance.

Community Alums
Not applicable

Hi @Vee Jay Recana ,

, if there are multiple conditions in query, the conditions are ANDed. To use ORs or create technically complex queries, use encoded queries. The code for using an encoded query looks like this:

var myObj = new GlideRecord("x_snc_needit_needit");
myObj.addEncodedQuery('<your_encoded_query>');
myObj.query();
while(myObj.next()){
  // Logic you want to execute for the GlideRecord records
}

Use this script for your refernce :

https://www.servicenow.com/community/developer-forum/is-there-a-way-to-filter-specific-users-from-th...