Including TestStand Variables in SystemLink Email Notifications

Updated Oct 8, 2024

Environment

Software

  • SystemLink Server
  • TestStand

This article demonstrates how to add custom test result data to a SystemLink email notification. 

TestStand sequences can be configured to send an email to a recipient, defined in the Alarms and Notifications >> Notifications >> Email Templates section of SystemLink Server, on completion of the test sequence. The steps in this article discuss how to add custom data to the email body using TestStand PropertyObjects.

Before proceeding, ensure that the TestStand has been integrated with SystemLink, as defined in Integrating Test Monitor with TestStand. Follow the steps below once complete:

1. In a browser, access the SystemLink Server and login.
  • The server URL can be found on the Applications tab of NI Web Server Configuration.
2. From the menu, expand Utilities and select Alarms to redirect to the Alarms and Notifications page.

SL alarms page.PNG

3. Select the Email Templates tab from the left-hand menu.
4. From the Selected Template drop-down menu, select the TestStand Sequence Completed Email Template.
  • If this option does not exist, click New and configure a template name, subject and body that follows the format below.
5. Underneath the Start Time, add the line Custom Property: <TestProperty>. Click Save when complete. 
  • This line references a TestStand variable called TestProperty, so that the email will display it's value. This property does not yet exist, but later steps will show you how to create it in your sequence.
SL email template.PNG
6. Launch TestStand and open the Sequence File that you wish to add email notifications to.
  • For demonstration purposes, this article refers to a sequence file called "Add property to Email Notification", which consists of a simple Pass/Fail Test.
7. In the Variables Pane, create a new Local Variable called EmailTemplates.
  • Right-click under the Locals('MainSequence') section and select Insert Local >> Array of >> Container.
  • When prompted to set the array bounds, leave the default configuration and click OK.
  • Rename the variable to EmailTemplates.
EmailTemplates variable.PNG

8. From the Insertion Palette, under SystemLink, place a Get Email Templates step.
  • In the Get Templates tab, set Template Parameter Name (Out) to Locals.EmailTemplates.
Get Email Templates step.PNG

9. From the Insertion Palette, under SystemLink, place an Email Notification step.
  • In the Send Email tab, enter your recipient's email address as a string in the Recipient input.
  • Select the conditions under which the email notification should be sent. In this example, an email is sent whenever the test sequence passes, fails, errors or terminates.
  • In the Template ID (optional) input, enter Locals.EmailTemplates[i].Id where i represents the numeric index of the email template to use. For example, if the "TestStand Sequence Completed Email Template" is the fourth template to appear in SystemLink, then it's index will be 3.
Send Email Notification Step.PNG

10. In the Sequences pane, add a PreUUT Callback.
  • Right-click in the empty space and select Sequence File Callbacks.
  • In the pop-up window, select PreUUT and click OK. The PreUUT Callback should now appear in the Sequences pane.
PreUUT Callback.PNG

11. Create a new PropertyObject in the PreUUT Callback.
  • In the Variables Pane, right-click in underneath Locals ('PreUUT') and select Insert Local >> Object Reference. Name the variable TemporaryObjectReference.
  • From the Insertion Palette, add a Statement step to the Main sequence and call it Create New PropertyObject.
  • Enter the expression below to create a temporary string PropertyObject with the name "TestProperty". Note: "TestProperty" must match the name of the custom tag added to the SystemLink email template in step 4. 
Locals.TemporaryObjectReference = RunState.Engine.NewPropertyObject(PropValType_String,False,"",0),
Locals.TemporaryObjectReference.AsPropertyObject.Name = "TestProperty"


Create new propertyobject.PNG

12. Insert a new property into the PreUUT Callback parameters.
  • Place another Statement step and call it "Insert Property into Locals".
  • Enter the following expression to add the newly created PropertyObject as a sub-property of the PreUUT Parameters.
Parameters.UUT.AdditionalData.InsertSubProperty("",0,0,Locals.TemporaryObjectReference)

Insert property into locals.PNG


13. Assign a value to the PropertyObject.
  • Place another Statement step and add the following expression to assign a value of Hello World to the PropertyObject.
 #NoValidation(Parameters.UUT.AdditionalData.TestProperty = "Hello World")

Assign value to property.PNG

14. Execute the sequence in Single Pass mode, and observe the custom property value in the SystemLink email notification.