You are currently reviewing an older revision of this page.
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>