Developers Tessitura Community
  • Topical Tessitura Community Groups
  • More
Developers Tessitura Community
Community Docs Wiki Show Information from a Custom Data Service
  • Discussions
  • Community Docs Wiki
  • Events
  • Files
  • Members
  • Mentions
  • Tags
  • More
  • Cancel
  • New
Developers Tessitura Community requires membership for participation - click to join
  • +Community Developer Documentation
  • Browser-based custom screen auth token API authentication
  • Deploying network ticket printers via Windows Group Policy
  • -HTML Templates
    • Show Information from a Custom Data Service
    • Show information from a custom stored procedure
    • Tips for writing HTML Templates
  • +Impresario Database
  • List Filters in Custom Reports
  • New to Using Tessitura in a Software Developer Role? Start here!
  • SSRS Report Open Detail Window Links
  • The Secret Life of HTML Templates
  • +TNEW Customizations
  • Understanding Contributions endpoints in the REST Services

Show Information from a Custom Data Service

This is an example of fetching and displaying in an HTML Template e-mail, arbitrary data from a custom Data Service Table/View stored in TR_DATASERVICE_TABLES.  Updates/edits welcome.

In this example, we reference a local database view LVXS_CP_ORDER_PRIMARY_ORG with the name CPOrdersPrimaryOrg and unique key column of order_no.  Sample reason this might be needed is in a consortium environment where orders might feature products from multiple organizations and there is a need to determine a primary/joint style/content template for the e-mail.

@* Sample get single custom dataservice element based on ID *@

@* Use Newtonsoft.Json for parsing *@
@using Newtonsoft.Json;
@using Tessitura.Services.Common.Client.Utils;

@* Define object CPOrderOrg for properly named and typed results *@
@functions
{       
    public class CPOrderOrg
    {
        [JsonPropertyAttribute("organization")]
        public int OrgId;
        [JsonPropertyAttribute("org_desc")]
        public string OrgDesc;
    }
}

@* Define URL for and get data from custom dataservice entry CPOrdersPrimaryOrg based on the Order ID; single object results *@
@{
    @* Order ID is provided in the Order Confirmations template type *@
    var customURL = "Custom/CPOrdersPrimaryOrg/" + Model.OrderProductView.Id;
    var orderPrimaryOrg = Model.RestClient
        .AtUrl(customURL)
        .WithContentType(ContentType.Json)
        .Get<CPOrderOrg>()
        .ResponseObject;
}

@* Output results *@
<p>
    @orderPrimaryOrg.OrgId
    @orderPrimaryOrg.OrgDesc
</p>

  • HTML Templates
  • razor
  • REST API
  • Share
  • History
  • More
  • Cancel
Related
Recommended