CM.Resource Pool - Templates for Resource Data

Introduction to Using Templates for the Display of Resource Data

In the ConSol CM Web Client, resource data sets are displayed in short form at various locations, based on templates. For example, in the ticket history, the resource name, inventory number and location might be required, whereas in the Quick Search only the name and inventory number should be displayed. This section will show you where short forms are used and how the respective templates are configured using the Admin Tool.

Templates are always defined for a Resource Type. In our example, HP_Printer is a Resource Type, i.e., the templates will be valid for all real-world HP printers which are stored in the ConSol CM system.

The configuration is based on the following principle (very similar to the display of customer data):

Creating and Editing Resource Data Format Templates

To create and edit resource data format templates, edit the desired Resource Type in the Admin Tool and enter the names of the templates. Name them however you like resp. following any naming conventions defined by your organization.

Figure 467: ConSol CM Admin Tool - Resource data format template definition for a Resource Type

In the next step, you have to create the respective templates and store them in the Scripts and Templates section, as described in the following section.

Coding Resource Data Format Templates

General Principle

The templates are written in FreeMarker notation. For detailed information, please refer to the FreeMarker web site.

Within the templates, you work with three object types:

  1. resource: this is the current resource object
  2. the technical name of the Resource Field Group
  3. the technical names of the Resource Fields

Please note that there might be more than one Resource Field Group within a Resource Type!

Figure 468: ConSol CM Admin Tool - Objects used in resource data template definition

The resource templates must be single-row! They must not contain line-breaks!

Examples for Templates

// Example 1

// Resource Field group is named vehicleProperties, Resource Fields are named vehicleIdentification and vehicleLicense

${resource.get("vehicleProperties", "vehicleIdentification") + ' (' + resource.get("vehicleProperties", "vehicleLicense") + ')'}

// Example 2

// // Resource Field group is named publicTransportProperties, Resource Fields is named passName

${resource.get("publicTransportProperties", "passName")}

Template Types

The following Template types can be defined:

Default

This template must always be defined. If it is not, there will be an error in the Web Client (unknown is displayed as name of all resources of this type). The template will be used for all locations in the Web Client for which no other templates have been defined and will also be used as REST template for CM.Track in case there is no dedicated Rest template. The templates which are described in the subsequent sections will override the default template for the specific Web Client location

HP Printer: ${resource.getFieldValue("HP_Printer_Fields_basic","inventory_number")!}

The template is used for

Quick Search

This template defines the format of the resource data in the result of the Quick Search. For an example see section Quick Search.

Search

This template defines the format of the resource data in the result of the search (in suggestion lists) for resources when a resource is linked to another object, e.g., a ticket. For an example see section Search.

Rest

This template defines the format of the resource data in the result of the REST API. In the standard configuration, no customer data are displayed in the ConSol CM portal, CM.Track, which is based on the REST API. This template will only be effective when you address the REST API directly, e.g., for programming with ConSol CM interfaces. For an example see section Rest.

History

This template defines the format of the resource data in the result of the ticket, customer and resource history, e.g., when a relation to or from a resource was added. For an example see section History Sections of Resource Page, Customer Page and Ticket.

Web Client Locations for the Use of Templates

The following locations are specified:

Header of the Resource Page

Figure 469: ConSol CM Web Client - Header of the resource page

Used template: Default (see example above)

Dragged Resource in Drag-and-Drop Operations

ConSol CM Web Client - Dragged resource in drag-and-drop operations

Used template: Default (see example above)

Favorites

Figure 470: ConSol CM Web Client - Resource name in Favorites

Used template: Default (see example above)

Quick Search

Figure 471: ConSol CM Web Client - Results for Quick Search (resource)

Used template: Quick Search, if this is defined. If not, Default.

HP Printer: ${resource.getFieldValue("HP_Printer_Fields_basic","name")!} - ${resource.getFieldValue("HP_Printer_Fields_basic","inventory_number")!}

Search

Figure 472: ConSol CM Web Client - Resource in suggestion list, format based on search template

Used template: Search, if this is defined. If not, Default.

HP Printer: ${resource.getFieldValue("HP_Printer_Fields_basic","name")!} - - ${resource.getFieldValue("HP_Printer_Fields_basic","IP_address")!}

History Sections of Resource Page, Customer Page and Ticket

The history template for a resource will be displayed, for example, in the ticket history for the extended level, if Show all entries has been selected.

Figure 473: ConSol CM Web Client - History template for resource data

Used Template: History, if this is defined. If not, Default.

REST

The following example shows a REST client request for resource data and the resulting answer of the ConSol CM server via REST API. The value within the <mark> tag in the XML output is the resource information which is formatted using the REST template. In the example, the resource name (My new HP Printer) and the inventory number (4712) are part of the template.

Figure 474: REST API - List of all resources

Figure 475: REST API - Details of one selected resource (ID 2)

HP Printer: ${resource.getFieldValue("HP_Printer_Fields_basic","name")!} - ${resource.getFieldValue("HP_Printer_Fields_basic","inventory_number")!}

Used template: REST, if defined. If not, Default.