Ever wanted to be able to add a Custom item to the UI16 User Menu? Then here is something that may help.

As you may know, ServiceNow utilises Jelly, so if you know the correct name of a UI Macro or UI Page, you will be able to change, add or even remove various elements from the UI. As we are talking about the the User Menu in UI 16, this is actually managed by a UI Macro called “concourse_user_menu.

To get to this UI Macro, navigate to System UI –> UI Macros, then search for “concourse_user_menu”.

Below is a small but useful Menu Item I created for a customer, which allowed an ITIL user to unassign all their tickets as well as providing an update on all the tickets to state why they’ve unassigned. This was a requirement due to the users being in a 4-on-4-off shift basis, and they wanted all the users tickets to be unassigned at the end of their 4 day shift.

Within the “concourse_user_menu” UI macro, I added the below snippet of code to provide a list item to navigate to a UI Page called “UnassignMyTickets”, which required the user to have the ITIL role in order to see.

<j2:if test="$[gs.getUser().hasRole('itil')]">
      <li role="presentation">
        <a href="nav_to.do?uri=UnassignMyTickets.do" role="listitem">
          Unassign My Tickets
        </a>
      </li>
</j2:if>

Below is the configuration details of the UI Page called “UnassignMyTickets”

Name: UnassignMyTickets
HTML

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<g:ui_form>
	<div>
		<h1> Unassign My Tickets </h1>
		<p style="font-size:16px">
			Please select a reason why you are unassigning all your tickets.
		</p> <br/>
	<g:ui_choice_input_field id="unassign_reason" name="unassign_reason" label="Unassign Reason">
		<option value="Going off shift">Going off shift</option>
		<option value="Annual Leave">Annual Leave</option>
		<option value="Sick">Sick</option>
	</g:ui_choice_input_field >
		<br/>
			<p style="font-size:16px">
			By clicking "OK" all of your tickets will be unassigned.
			<br/>
		<button class="btn btn-primary" id="ok_button" onclick="return true" type="submit">
			Unassign Now
		</button>
	</p></div>
	</g:ui_form>
</j:jelly>

Processing Script:

function UnassgnAllMyTickets(){
	try{
	var user = gs.getUserID();
	var username = gs.getUserName();
	var inc = new GlideRecord("task");
		inc.addQuery('active', true);
		inc.addQuery('assigned_to', user);
		inc.query();
		var inclist = "";
	while (inc.next()) {inc.assigned_to = "";
						inc.work_notes = "Ticket has been unassigned from " + username + "\nReason: " + unassign_reason;
						inc.update();
						inclist += inc.number + " , ";
						gs.info(user + "\n" + "Ticket has been unassigned from " + username + "\n" + unassign_reason);
						}
		gs.addInfoMessage("Tickets successfully Unassigned \n" + inclist );
		var url = 'home.do';
		response.sendRedirect(url);
	}
catch (ex){ gs.info(user +"\nFailed\n" +ex);}}
UnassgnAllMyTickets();

Once created, this allows the User to select the “Unassign My Tickets” option in the User Menu (see below) and they will be taken to a page.

The Unassign My Tickets page is a very straight forward page which allows the user to select from 3 different reasons for unassigning their tickets, which is then added as a part of a work note on every ticket that’s been unassigned. Adding more options is just as simple as modifying the HTML section on the UI Page.

Categories: Uncategorized

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *