Hadyn
Tera Expert

I wanted an unimpersonate button in my service portal user dropdown menu so I can easily unimpersonate when I finished impersonating someone who only had access to the portal and not UI16.

You will need to clone the Stock Header widget sp_header_footer.do?sys_id=bf5ec2f2cb10120000f8d856634c9c0c

Update Body HTML template

<ul class="dropdown-menu" role="menu" aria-label="{{::data.profileBtnMsg}}">
            <li role="presentation"><a tabindex="-1" ng-href="?id=user_profile&sys_id={{::user.sys_id}}" role="menuitem">${Profile}</a></li>
            <li ng-if="data.isImpersonating" role="presentation"><a href tabindex="-1" ng-click="unimpersonate()" role="menuitem">${Unimpersonate}</a></li>
            <li ng-if="::!isViewNative" role="presentation"><a tabindex="-1" href="{{::portal.logoutUrl}}" role="menuitem">${Logout}</a></li>
          </ul>

 Update Server Script and add this at the top line

data.isImpersonating = new GlideImpersonate().isImpersonating() || false;
if(input && input.unimpersonate == true){
	gs.getSession().onlineUnimpersonate();
}

Update Client Controller

	$scope.unimpersonate = function() {
		$scope.server.get({unimpersonate:true}).then(function(response){
			top.location = "/";
		});
	};
Comments
will_leingang
ServiceNow Employee
ServiceNow Employee

Great idea, Hadyn!

Version history
Last update:
‎12-05-2018 06:19 PM
Updated by: