Limiting @mention functionality

Weird
Mega Sage

I've been inspecting how the @Mention works and based on transactions it's based on some API path "/api/now/form/mention/record/...".
I created a before query BR in sys_user table to limit the users returned by the mention and it seems to work in most cases, but there are cases when a user can be mentioned even though they do get filtered out by the query.

Here's an example.
My BR blocks users from company "X" if "gs.action.getGlideURI" contains "api/now/form/mention".
I go to demand table and open a record. There's a "Opened by" user "U" who is from company "X". If I start writing the users's name in mention they show up and I can select them. If I go to another record the user won't show there.
I tried removing the user from the "Opened by" field and event changed the "Created by" value, but user U is still available for selection on the first demand.

Why? What does Servicenow do in the background that would prevent query rule form triggering for a user in this case? How can I block this?

2 REPLIES 2

MattSN
Mega Sage
Mega Sage

Similar at least.

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

		if (gs.action.getGlideURI().toString().indexOf('api/now/form/mention/record') > -1) {

			var query = 'company=78ef6fbcdbe722002f9ebc2ffe961954^active=true'; 
			current.addQuery(query);
		}
	} catch (err) {
		//no logging
	}

})(current, previous);

Before query on sys_user table. I haven't included any other conditions, so it runs for every query.