
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 12:12 AM
Hi Team, how can we limit the users to be selected in impersonation window? We have a requirement to allow only approved users to be available for impersonators to impersonate.
Solved! Go to Solution.
- Labels:
-
Instance Configuration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2018 07:41 AM
Thank you @iamkalai, I have used below condition in before query BR on sys_user table, and it works.
Condition: gs.getSession().isInteractive() && gs.action != ''
Script: if ((gs.action.getGlideURI().toString()).indexOf('impersonate') != -1 || (gs.action.getGlideURI().toString()).indexOf('angular.do?sysparm_type=ref_list_data') != -1) {
<YOUR CODE GOES HERE>
}
NOTE: Do not add above if condition in the condition field, orelse you will get java null pointer exception while updating record in sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 12:31 AM
Hi,
https://community.servicenow.com/community?id=community_question&sys_id=7721dbe9dbdcdbc01dcaf3231f9619da
try with this link..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 02:31 AM
Thank you Preethi, I am currently using the script include. But this is not what I want.
I want to limit the selection of the user in impersonation window itself.
Impersonator should view only limited users in the impersonation selection window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 03:17 AM
Hello Vikas,
Quick easy way ( not the best solution ) but f you can customize the ui macro , you can modify : sys_ui_macro.do?sys_id=1bf0cfd0eb1321001c13abf11206fee4 - impersonate_dialog ui macro
line 24 - 37
<j:if test="${actual_user.hasRole('admin')}">
<j:set var="jvar_impersonate_query" value="QUERY:active=true^locked_out=false^web_service_access_only=false^ORweb_service_access_onlyISEMPTY" />
</j:if>
<j:if test="${!actual_user.hasRole('admin')}">
<j:set var="jvar_impersonate_query" value="QUERY:active=true^locked_out=false^web_service_access_only=false^ORweb_service_access_onlyISEMPTY^roles!=admin" />
</j:if>
<input id="impersonate_query" type="hidden" value="${jvar_impersonate_query}" /><br/>
<label for="${jvar_impersonate_query}" class="sr-only">
${gs.getMessage('Search for user')}
</label>
<g:ui_reference name="${jvar_impersonate_query}" table="sys_user" onchange="clearSelect()"/>
</div>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 03:32 AM
I tried modifying the query form what you gave but doesn't changed anything...