Skip Navigation LinksALVAO 10.1ALVAO Service DeskSystem Implementation in an OrganizationCustom Edits and ExtensionsCustom Program ExtensionsCustom Tabs in Request Detail Skip Navigation Links. Skip Navigation Links Skip Navigation Links.


Custom Tabs in Request Detail

Custom tabs can be used to display custom content in the request detail. It can be custom form within the Service Desk WebApp or e.g. external parametrized link.

Warning:
The ALVAO database can be permanently damaged if a custom tab is defined incorrectly; therefore, always use a copy of the database in the test environment to perform creation and testing.
Warning:
In the tabs you cannot display pages for which displaying in their frame is disabled. Neither in console nor in the WebApp.
Tip:
Creating a working custom tab requires good knowledge of the ALVAO database and the Service Desk WebService interface.

Preparing a new custom tab

In the folder where ALVAO Service Desk WebService is installed, copy the CodeExtension_Template.cs file in the App_Code folder and rename it according to the content displayed by the tab.

In the newly created file, enter a definition of the new tab into the bordered code block by implementing the IView interface and set the values for the id and name properties in the command class constructor.

  • id – tab number (unique)
  • name – tab name displayed in the applications

Example

If the request is in the service and has the status defined in the class described below, a tab with the requester's (organization's) address shown on a map will be displayed in the request detail.

1st part of the example:


class ShowRequesterAddress : IView
{
   public int id { get; set; }
   public string name { get; set; }

   public ShowRequesterAddress()
   {
       id = 1;
       name = "Requester address";
   }

   int sectionId = 1; // ID of the service for whose requests the tab is to be displayed
   string stateName = "Personal meeting with requester"; // The name of the request status needed for the tab to be displayed

}

Defining the conditions for displaying the custom tab content

In the created tab class, implement the Show method from the IView interface. Input parameters are ticketId (request number) and personId (id of a person who should the tab be displayed to).

Output is then a text string containing URL for displaying on the custom tab. If the URL is empty, the tab is not displayed to the user.

2nd part of the example:


class ShowRequesterAddress : IView
{

   public string Show(SqlConnection Con, SqlTransaction Trans, int ticketId, int personId)
   {
       string url = "";

       // loading necessary request data from the database
       using (SqlCommand Cmd = new SqlCommand(@"
       SELECT
         ZAA.Street + '' + ZAA.City requester_address,
         liHdTicketHdSectionId,
         sHdTicketStateNotice
       FROM
         tHdTicket HDT
         JOIN tPerson Z on Z.iPersonId = HDT.liHdTicketUserPersonId
         JOIN tAccount ZA ON Z.liAccountId = ZA.iAccountId
         JOIN tAddress ZAA ON ZAA.id = ZA.AddressId
       WHERE
         HDT.iHdTicketId = @iHdTicketId", Con, Trans))
       {
           Cmd.Parameters.Add("@iHdTicketId", SqlDbType.Int).Value = ticketId;
           Cmd.Parameters.Add("@iPersonId", SqlDbType.Int).Value = personId;

           int section; // id of the service where the request is located
           string state; // request status
           string requesterAddress; // requester address (by organization)

           using (SqlDataReader ticketReader = Cmd.ExecuteReader())
           {
               if (ticketReader.Read())
               {
                   section = int.Parse((ticketReader["liHdTicketHdSectionId"]).ToString());
                   state = (ticketReader["sHdTicketStateNotice"]).ToString();
                   requesterAddress = (ticketReader["requester_address"]).ToString();
               }
               else
               {
                   return url;
               }
               ticketReader.Close();
           }

           // checking whether the request is in the required service and has the required status
           if (section == sectionId && state == stateName)
           {
               // the returned url shows the requester's address on the map in a separate tab
               WebClient APIClient = new WebClient();
               var SAPI = new Uri(HttpUtility.UrlPathEncode("http://api.mapy.cz/geocode?query=" + requesterAddress));
               APIClient.Encoding = System.Text.Encoding.UTF8;
               string XMLresponse = APIClient.DownloadString(SAPI);
               XmlDocument APIresponse = new XmlDocument();
               APIresponse.LoadXml(XMLresponse);
               var APIitems = APIresponse.GetElementsByTagName("item");
               if (APIitems.Count >= 1)
               {
                   var Atributes = APIitems.Item(0).Attributes;
                   var Query = new StringBuilder("q=");
                   Query.Append(requesterAddress);
                   foreach (XmlAttribute Atribute in Atributes)
                   {
                       Query.Append('&');
                       Query.Append(Atribute.Name);
                       Query.Append('=');
                       Query.Append(Atribute.Value);
                   }
                   url = HttpUtility.UrlPathEncode("http://mapy.cz/zakladni?" + Query.ToString());
               }
               return url;
           }
       }
       return null;
   }

}

The whole example can be downloaded here.

Note:
In the example you work with classes whose libraries are not a component of the CodeExtension_Template.cs default file. These classes are WebClient, XmlDocument, and StringBuilder. In order to make the example work add these libraries at the beginning of the file:
using System.Net;
using System.Xml;
using System.Text;
Tip:
If the custom tab should display another page from ALVAO WebApp, use the GetServiceDeskPortalUrl() method from the Service Desk Web Service interface to find the root URL of WebApp. E.g.:
string waUrl = "";
using(HelpdeskWebService ws = new HelpdeskWebService())
{
    waUrl = ws.GetServiceDeskPortalUrl();
}
if (waUrl.Length == 0)
    throw new Exception("WebApp address not set.");

 

Did not find what you were looking for? Ask our technical support team.