Developers Tessitura Community
  • Topical Tessitura Community Groups
  • More
Developers Tessitura Community
Community Docs Wiki HTML Template Email Queue Tables
  • 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
  • -Impresario Database
    • Constituent Relationship Join Views
    • HTML Template Email Queue Tables
    • Measure and improve SQL query performance
  • 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

HTML Template Email Queue Tables

T_TEMPLATE_QUEUE and T_TEMPLATE_QUEUE_PARAMETER are likely to appear in the next version of the Table Structures document, but until they do, here are some tips:

Known Values of T_TEMPLATE_QUEUE.status:

  • 0: Pending
  • 1: Sent successfully
  • -1: Failed with error

Practical takeaway: if you want to use T_TEMPLATE_QUEUE as state, by querying it to exclude orders that have already received a certain template, make sure your exclusion filters on status <> -1 instead of status = 1.

If you are queuing emails by inserting directly to these tables, AND YOU NEED TEMPLATE PARAMETERS, you have a couple of coding considerations:

  • T_TEMPLATE_QUEUE_PARAMETER is foreign-keyed on the identity column of T_TEMPLATE_QUEUE
  • rows in both of these tables are required for your template to send successfully, so you can't allow the TPS to pick up a T_TEMPLATE_QUEUE row before you've added the matching parameter rows.

The correct coding conventions to accommodate these requirements are to insert to both tables in an explicit transaction, and to use an INSERT-OUTPUT clause to get the generated identity IDs. Here is an example:

BEGIN TRANSACTION;

CREATE TABLE #inserted (
  id int,
  reference_no int,
);

INSERT dbo.T_TEMPLATE_QUEUE
      (template_no, email_profile_no, request_userid, request_usergroup, email_address, reference_no)
  OUTPUT INSERTED.id, INSERTED.reference_no INTO #inserted
SELECT template_no, email_profile_no, request_userid, request_usergroup, email_address, reference_no
  FROM #inserting;

WITH inserted_keyed AS (
  SELECT
      template_queue_id = id,
      reference_no,
      order_sli_key = ROW_NUMBER() OVER (PARTITION BY reference_no ORDER BY id)
    FROM #inserted
), inserting AS (
  SELECT
      k.template_queue_id,
     [name] = 'sli_no',
     [value] = CONVERT(varchar, i.sli_no)
    FROM inserted_keyed k
      JOIN #inserting i
        ON k.reference_no = i.reference_no
          AND k.order_sli_key = i.order_sli_key
)
INSERT dbo.T_TEMPLATE_QUEUE_PARAMETERS
      (template_queue_id, [name], [value])
SELECT template_queue_id, [name], [value]
  FROM inserting;

COMMIT TRANSACTION;
  • Share
  • History
  • More
  • Cancel
Related
Recommended