Make the Current Machine the Top Choice in the Asset Dropdown List for End Users

Make the Current Machine the Top Choice in the Asset Dropdown List for End Users

In the standard Helpdesk code, the winuser console (My Helpdesk Console) provides end users with a dropdown list which will allow them to specify the name of the asset that has the problem. This is populated by the list of assets associated with the user and the first and hence default record is set to None.

While this default behavior might be valid for many organizations, others may consider it a potential drawback for the following reasons:

  1. The end user may not know the name of the machine they are using.
  2. There is no obligation on the user to select an asset and most users do not appreciate the utility of selecting the resource. They just want their problem fixed as soon as possible and may not be in a very good mood. They may not even notice the dropdown list.
  3. The resource may not be associated to the user and so may not show up in the list.
  4. In some situations there is not a fixed relationship between users and computers.

As long as you are in an environment where you can do a reverse lookup on the DNS server, the following modification allows you to have the name of the machine that is being used to create the incident as the first item in the dropdown list of assets. Users are still free to select the None option or any other asset associated with their contact ID.

1. Create a custom console file.

First, as in all customizations, we must make a folder called "custom" in the AeXHD\winuser directory and copy the template we wish to edit into this folder. In this case we are editing the ConsoleMyHD.ascx template, so we copy this file into our custom folder and rename it CustomConsoleMyHD.ascx.

Make the following edits to the CustomConsoleMyHD.ascx file:

2. Add this code to the end of the subroutine LoadDataSources just before the End Sub command.

Dim strComputerFQDN As String = System.Net.Dns.GetHostByAddress(HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST")).HostName 
Dim delimStr As String = "." 
Dim delimiter As Char() = delimStr.ToCharArray() 
Dim strComputerName As String() = strComputerFQDN.Split(delimiter) 
Dim l As ListDataSet = New ListDataSet("SELECT managed_object_id, managed_object_name FROM managed_object_view WHERE managed_object_name = '" & strComputerName(0) & "'") 
l.Tables(0).TableName = "ThisAsset" 
DataStore("LocalAsset") = l

3. Insert the following code into the GetFirstPage function (existing code in italics):

....If Command("page") = "pvNewItem" then 
GetFirstPage = "pvNewItem" 
pvNewItem.DataBind() 
If DataStore("LocalAsset").Tables("ThisAsset").Rows.Count = 1 Then 
Dim dr as DataRow = DataStore("LocalAsset").Tables("ThisAsset").Rows(0) 
Dim li as System.Web.UI.WebControls.ListItem = new System.Web.UI.WebControls.ListItem(dr.Item("managed_object_name").ToString(),dr.Item("managed_object_id").ToString()) 
If Not ddlAsset.Items.Contains(li) Then 
ddlAsset.Items.Remove(li) 
End If 
ddlAsset.Items.Insert(0,li) 
End If 
Console.Focus = tbTitle 
Else... 

4. In the ASP.NET code locate the line ID="chsAssets" and edit it as follows:

<aw:Choose ID="chsAssets" Value='<%# DataStore("Contact").Tables("AssociatedAssets").Rows.Count OR DataStore("LocalAsset").Tables("ThisAsset").Rows.Count %>' RunAt="server" Label="sidLblAsset">

What all this will do is to resolve the machine name from the DNS server. If it gets a name it will try to find the asset record for this machine. If it succeeds it will set the asset name as the first record in the dropdown list.

Now we need just need to tell the HD to use our custom console in place of the standard console:

5. Create a file called custom.config in the AeXHD folder.

Add the following XML code to the custom.config file:

<?xml version="1.0" encoding="utf-8" ?>
<custom.configuration>
  <files path="~/winuser/custom/">
    <file id="ConsoleMyHD" file="CustomConsoleMyHD.ascx" />
</files>
</custom.configuration>

To activate the console, restart the IIS service on the server by opening Start > Run… Type iisreset and press OK.

Now when a user attempts to open an incident, they will find the asset they are currently using as the first item in the dropdown list.

3.916665
Average: 3.9 (12 votes)

Great Thought

jsjj01's picture

Probably the single biggest problem we have is ensuring that the proper asset information is in the help desk. Using this feature will hopefully help in solving this ongoing issue. Thanks.

file change

I believe that the file must have changed since this post was created. I was having a hard time finding the code you had then noticed that the new filename for the process you were refering to seems to now be ConsoleMyHDEditItem.ascx.

-------------
Adam Gilman
Sr. Helpdesk Analyst
Dolphin Staffing

Error attempting this

scott76's picture

Can some one tell me what I am doing wrong.

Public Overrides Sub LoadDataSources()
    
    ' Standard lookups
	DataStore("Priorities") = New ListDataSet("PriorityList")
 
	' Get the current contact info
	DataStore("Contact") = New ContactDataSet(CurrentWorker.worker_contact_id)
	DataStore("Contact").BeginEdit	

	' If we're being invoked with context then we need to load an existing work item,
	' otherwise create a new one
	Dim w as WorkItemDataSet
	if Command("id") <> "" AndAlso Command("id") <> "new" then
		w = new WorkItemDataSet(Command("id"))
		w.current.workitem_comment = ""
		w.History.DefaultView.RowFilter = "workitem_comment_visible_to_guest='1'"
		DataStore("WorkItem") = w
	else
		' Create WorkItem datastore to be used for creating an item
		w = new WorkItemDataSet("new")
		w.current.workitem_comment = ""
		w.current.workitem_status_lookup_id = 200
		w.current.workitem_contact_id = DataStore("Contact").current.contact_id
		DataStore("WorkItem") = w
	end if

	' SP5 - Check if HttpRequest provides data to be poked into data sources
	' This must be done after the datasources are enabled for editing and before
	' DataBinding into the template controls.
	ReverseDataBindFromRequest("WorkItem", "")
Dim strComputerFQDN As String = System.Net.Dns.GetHostByAddress(HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST")).HostName 
Dim delimStr As String = "." 
Dim delimiter As Char() = delimStr.ToCharArray() 
Dim strComputerName As String() = strComputerFQDN.Split(delimiter) 
Dim l As ListDataSet = New ListDataSet("SELECT managed_object_id, managed_object_name FROM managed_object_view WHERE managed_object_name = '" & strComputerName(0) & "'") 
l.Tables(0).TableName = "ThisAsset" 
DataStore("LocalAsset") = l

End Sub


Public Overrides Function GetFirstPage() As Object
	If Command("action") = "new" then
		GetFirstPage = "pvNewItem"
		pvNewItem.DataBind()
		Console.Focus = tbTitle
	Else
		GetFirstPage = "pvItem"		
		If DataStore("WorkItem").UpdateLocked Then 
			cbLocked.Visible = "True"	
			lblLocked.Visible = "True"
			hlRefresh.Visible = "True"		
		End If
		pvItem.DataBind()
	End If

	Title = TryString("sidMyHD")

End Function

Still working for anyone?

I am trying to implement this but it is not working for me. I am getting external exception on the webpage when it tries to refresh. Running the latest Helpdesk Solution as of April 30th, 2008.

Asset Top Choice

dclaxton's picture

This code must be added to the ConsoleMyHDEditItem.ascx file as oppose to the ConsoleMYHD.ascx file in order for this to work with SP5.

It works rather well.

DC