Skip to main content
Kinetic Community

Custom Event Type Output Format

The Related Info section that displays additional field information for an event can be rendered using a custom JSP, giving the calendar manager control over how this information is displayed. This allows information to be combined, images or hyperlinks can be added, or the information can be displayed in a different layout rather than displayed as a table of label/value pairs. This example shows how to display a hyperlink to open the event record in MidTier, which will allow the user to view more information about the event, or even to change the event information.

Resolution

In order for Calendar to use a custom JSP file, there are a few steps that need to be performed to allow this to happen.

  1. The first step is to write a JSP that will get this information and present it to the user.  An example file is attached, and each part will be described in detail in the JSP Code section below.
  2. Second, the JSP must be copied to the web application.  The file should be placed in the resources/ directory of the KinCal web application.
  3. Next, the JSP must be registered as an Event Type Output Format menu item in the Calendar Manager Console.
    1. ​Open the Calendar Manager Console as a Remedy Administrator user.
    2. Click on the Configuration link on the left hand side of the console.
    3. Click on the Menus tab to show the available menu items used in the application.
    4. Click the Add button to create a new menu item for the custom JSP page.
    5. Add Menu Item.jpg
    6. ​Fill in the appropriate information that describes this custom jsp menu item
      1. ​Menu Type - select Event Type Output Format
      2. Menu Label - this will be the value displayed to the user in the drop-down list of choices.  For this example, we will be using midtierLink_SithcoChange
      3. Menu Value - this must match the name of the jsp file, without the .jsp extension.  For this example, we will be using midtierLink_SithcoChange.  NOTE - the name is case sensitive.  Make sure the value corresponds to the file name.
      4. Make sure the Status is set to Active.
      5. The rest of the values can be left as the default values.
      6. Save the menu item.
  4. Finally, the event type must be configured to use this custom JSP page.
    1. ​Open the Event Type that is configured to display the events
    2. Click the Display Fields tab
    3. Change the Output Format drop-down selection to midtierLink_SithcoChange
    4. Save the Event Type configuration

 

JSP Code

This section explains the code involved with retrieving the information from the server, building up the MidTier link, and displaying it to the user.

 

The section at the top of the file defines the information needed to build up the URL for the midtier link:

String midtierServer = "midtier.companyname.com:8080";

String remedyServer = "remedy";
String form = "KS_CAL_SithcoChange";
 
 
 
Then the URL is built up to point to the MidTier server, indicating that the KS_CAL_SithcoChange form should be displayed:
// builds up the MidTier URL from the values provided above.
String url = "http://" + midtierServer + "/arsys/servlet/ViewFormServlet";
url += "?server=" + remedyServer;
url += "&form=" + java.net.URLEncoder.encode(form, encoding);
 
 
Some boiler plate code is then provided to setup the server response, and then build up the response as an XML document and then parse this document to get a list of all the fields related to the record being displayed.  This part of the file should not need to be touched.
<%
String encoding = "UTF-8";
 
// initialize variables that will be used to retrieve field data
Element fieldEl = null;
String fieldId = "";
String fieldName = "";
String fieldLabel = "";
String fieldData = "";
 
// get the serialized xml string of the event
String eventXml = (String)request.getAttribute("MoreInfo");
 
// convert the serialized xml to an xml document, and retrieve the result element
StringReader reader = new StringReader(eventXml);
SAXBuilder builder = new SAXBuilder();
Document eventDoc = builder.build(reader);
Element moreInfo = eventDoc.getRootElement();
Element result = moreInfo.getChild("result");
 
// get the event display fields
List fields = result.getChildren();
Iterator fieldsIterator = fields.iterator();
 
 
Now we get into the display portion of the code.  A fieldset element is created to provide some built-in browser styling and group the data together.  Then a table element is used to display the fields.  This portiion of display page can be customized to present the data in your desired format.
 
Within the table element, each field is examined to get the desired pieces of information that need to be displayed.
while (fieldsIterator.hasNext()) {
    fieldEl = (Element)fieldsIterator.next();
    if (fieldEl != null) {
        fieldId = fieldEl.getChild("fieldId").getText();
        fieldName = fieldEl.getChild("fieldName").getText();
        fieldLabel = fieldEl.getChild("fieldLabel").getText();
        fieldData = fieldEl.getChild("fieldData").getText();
 
This code shows how to get the four pieces of field information that are sent from the server.  The two pieces of information used in the table row display are the field label, and the field data.
<tr>
    <td style="border-bottom:1px solid #eaeaea;font-weight:bold;"><%= fieldLabel %>:</td>
    <td style="border-bottom:1px solid #eaeaea;"><%= fieldData %></td>
</tr>
 
After each field has been added to the table, the field id is examined to check if it is the Request Id, and if so, append it to the MidTier URL so the record can be loaded in MidTier.
if ("Request Id".equalsIgnoreCase(fieldName)) {
    // Add the request id as a URL parameter
    // encode the value to ensure all characters go through properly
    String recordId = java.net.URLEncoder.encode(fieldData, encoding);
    url += "&eid=" + recordId;
}
 
 
The table that holds the field data is then completed, and a link to open the URL in MidTier is created and displayed below the field data.
<a id="midtierLink" target="_blank" href="<%= url %>"
    style="display:block;margin:1em 0;color:blue;text-decoration:underline;">View Change record</a>
 
The resulting display looks like this:
Related Info.jpg
 
When the View Change record link is clicked, MidTier is opened in a new browser window to the Sithco Change form, and in this example, Request Id 000000000031086.
 
 

Conclusion

The full JSP code can be found in the attachments section below.