Skip to main content

Templates

Create a Record for Each Support Ticket

Templates are useful to quickly establish the foundation for a feature. This section will add a new command to the Support Ticket entity to generate an html page with a summary of the ticket.

NOTE: This tutorial is built upon the foundation of the Support Ticket application.

1. Prepare a Template

  • In Code > Templates click (+)
  • Set Name of Template to: Ticket Sheet
  • Verify that Template Code Language is set to: HTML
  • Verify that Model Type is set to: Entity
  • Set Model type to: Entity
  • Set Entity to: Ticket
  • Click Finish

Copy and paste the following:

<html>

<head>
<meta charset="UTF-8">
<style>
table {
border-spacing: unset;
margin: auto;
}

td {
padding: 10px;
border-bottom: 1px solid gray;
}
</style>
</head>

<body>
<table>
<tr>
<td>Title</td>
<td>@Model.Title</td>
</tr>
<tr>
<td>Severity</td>
<td>@Model.TicketSeverity.Name</td>
</tr>
<tr>
<td>Author</td>
<td>@Model.CreatedBy?.Name</td>
</tr>
</table>
</body>

</html>
  • Save: Ctrl + S

Optional: The Jetveo Platform can be customized with C# coding. Here, to add additional elements to the Ticket Sheet, add the following within the lower table:

        <tr>
<td>Assigned To </td>
<td>@Model.AssignedTo?.Name</td>
</tr>

<tr>
<td>Answer</td>
<td>@Model.DescriptionOfResolution</td>
</tr>

2. Prepare a Business Command

  • In Business > Commands and click (+) OR Type Ctrl + Shift + C and, in the Business section, select Command
  • Set Name to: Create Ticket Sheet
  • Set Type to: Entity command
  • Set Result type to: Document
  • Set Entity to: Ticket
  • Click Finish

Paste the following code:

{
var sheetHtml = App.Templates.TicketSheet.Render(ticket);
var sheetBytes = Encoding.UTF8.GetBytes(sheetHtml);
return new DocumentResult("ticket-sheet.html", sheetBytes);
}
  • Save: Ctrl + S

3. Add Command Action to Ticket Page

  • Go to UI > Entity pages and double-click Ticket detail
  • In Layout, click Add Action (in top part of layout editor)
  • Verify that Type is set to: Execute entity command
  • Set Entity Command to: Create Ticket Sheet
  • Click OK
  • Save: Ctrl + S

Your application will now generate a Ticket Sheet when you click on "Create ticket sheet" button in Ticket detail page.