Filter users for Activity Stream @mention

Lisa Holenstein
ServiceNow Employee
ServiceNow Employee

Hello,

we are importing users from our LDAP / Active Directory into our ServiceNow instance. Unfortunately we also need to import external, admin and other non-employee-users (to allow Service Requests, CI assignments, orchestration, etc.). Moreover, we still have > 10 Active Directories, which we are currently trying to harmonize into one Global AD, but we're not quite there yet.

However, if my IT colleagues now want to @mention one of the other infrastructure admins, they are presented with up to 14 different users (some admins have accounts in every LDAP) to choose from, which is very annoying and confusing. On most user reference fields, I have added a filter for u_employee_type == 'employee', but for my life I cannot find the correct spot where/how to filter the users specifically for the Activity Stream @mention Feature.

I hope that someone has a good idea!

Kind regards,

Lisa Holenstein



Have questions about the Now Platform? Join our bi-weekly Platform Academy.
1 ACCEPTED SOLUTION

I added an Infomessage, but it doesn't trigger on @mention. It triggers fine on picking a name in the email client ('EmailClient'), a pick field ('Reference') and so on, but it seems like the @mention is actually working differently.



gs.addInfoMessage('Variable ='+gs.action.getGlideURI().getMap().get('sysparm_processor'));



I used the BR for the email client anyways, it was a good tip, but unfortunately not solving my issue.



I did however find the correct condition in another community thread for disabling the @mention feature:


https://community.servicenow.com/message/1204758#1204758


gs.action.getGlideURI().toString().startsWith('api/now/form/mention/record/')



And that works just fine



Complete Business Rule:



On Before Query BR on Table "sys_user"


Condition: gs.getSession().isInteractive() && gs.action != ''


Script:


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



try


{


if(gs.action.getGlideURI() != '')


{


if(gs.action.getGlideURI().getMap()!= '')


{


if(gs.action.getGlideURI().toString().startsWith('api/now/form/mention/record/'))


current.addEncodedQuery('u_employee_type!=admin^ORu_employee_typeISEMPTY');


current.addActiveQuery();


}


}


}


catch(errObj)


{


gs.error('Global_Set_Filter_Mention-'+errObj);


}



})(current, previous);



Thanks everyone!




Have questions about the Now Platform? Join our bi-weekly Platform Academy.

View solution in original post

13 REPLIES 13

Kalaiarasan Pus
Giga Sage

I had done something like this for email client as I was in same situation with our users table.


Unlearn Series - Restrict Users On Email Client



You can reuse this and alter the parameters to fit your case.


Thank you for your quick answer, I didn't get around to test it yet, but it looks very promising. Do you by chance know what the parameter would be called for @mention?



Kind regards,


Lisa




Have questions about the Now Platform? Join our bi-weekly Platform Academy.

I am not sure. You can add few logs for the gs.action thing in the script and set the parameter for that according to your result.


I added an Infomessage, but it doesn't trigger on @mention. It triggers fine on picking a name in the email client ('EmailClient'), a pick field ('Reference') and so on, but it seems like the @mention is actually working differently.



gs.addInfoMessage('Variable ='+gs.action.getGlideURI().getMap().get('sysparm_processor'));



I used the BR for the email client anyways, it was a good tip, but unfortunately not solving my issue.



I did however find the correct condition in another community thread for disabling the @mention feature:


https://community.servicenow.com/message/1204758#1204758


gs.action.getGlideURI().toString().startsWith('api/now/form/mention/record/')



And that works just fine



Complete Business Rule:



On Before Query BR on Table "sys_user"


Condition: gs.getSession().isInteractive() && gs.action != ''


Script:


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



try


{


if(gs.action.getGlideURI() != '')


{


if(gs.action.getGlideURI().getMap()!= '')


{


if(gs.action.getGlideURI().toString().startsWith('api/now/form/mention/record/'))


current.addEncodedQuery('u_employee_type!=admin^ORu_employee_typeISEMPTY');


current.addActiveQuery();


}


}


}


catch(errObj)


{


gs.error('Global_Set_Filter_Mention-'+errObj);


}



})(current, previous);



Thanks everyone!




Have questions about the Now Platform? Join our bi-weekly Platform Academy.