It comes in handy when you want to send notifications to recipients that are to be computed dynamically based on the data. E.g. send a notification to all staff of the order’s business unit.
Can be also used to generate senders as well.
Step-by-step guide
-
Insert a new notification contact type into a database
In our example, we are going to extract a customer email from a booking (rental transaction). So this type of contact can be used in many notifications which involve that booking - e.g. various state changes (new, reservation expired, has been closed, etc.)If you have a multi-lingual application, you can add translations of the newly created contact type by inserting the records into the
WorkQueueNotificationContactType_l10n
table. -
Extend the
GetNotificationContacts
Workflow to handle our new contact type
The workflow is called from within the WorkQueue notification subsystem.The picture shows the target state of the workflow. So that’s it. The next steps will describe how to achieve this result.
-
Create a new data constant with an Id of your new notification data type
Data > Constants > YouPackageName > New > Data Constant -
Create an XPath rule to identify your contact type
Business Logic > Rules > YourPackageName > New > Start Rule
This rule we are going to use in the step of the workflow to identify and process only notifications with our notification contact type selected. -
In the
GetNotificationContact
workflow create a special step for processing our contact type.
FindGetNotificationContact
, right click and select New > Block (Transaction)
Create a workflow step/s with actual transformation (creation of a new AsapNotificationContact data structure)
GetNotificationContacts
has the following context stores:
Context Store | Type | |
---|---|---|
AsapNotificationContactData | Output | A data structure with a list of found contacts. This context store is a return one and it has to be filled with contacts.  |
asapNotificationChannelTypeId | Input | Email/Sms etc. (input) |
context | Input | Data from a data structure defined in our WorkQueue class as a NotificationStructure. If not defined, the context will contain the "raw" data of the WorkQueueEntry. |
value | Input | A value passed from Notification Senders/Notification Recipients tab on the Work Queue screen. It is an additional control value that can be added by a user in the Work Queue notification configuration screen. |
workQueueNotificationContactTypeId | Input | A type of notification contact. We already used this value for checking contact type in step 5. |
The transformation has to have a target context store set to AsapNotificationContactData
. We can create the transformation step by right-clicking on the AsapNotificationContactData
context and choosing Action > New Transform Task.Then we have to set a Data parameter of that transformation to Context so we have set the input for the transformation.
Now move the newly created transformation task under the block task with the NotificationContactType
condition.
Finally, create a transformation that will produce contact data similar as in the following example.
Transformation example
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:AS="http://schema.advantages.cz/AsapFunctions"
xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date">
<xsl:template match="ROOT">
<ROOT>
<xsl:apply-templates select="RentalTransaction"/>
</ROOT>
</xsl:template>
<xsl:template match="RentalTransaction">
<AsapNotificationContact
ContactIdentification="{@CustomerEmail}"
Name="{@CustomerName}"
refSalutationId="{@refCustomerSalutationId}"
>
<xsl:if test="string(@refCustomerLanguageId) != ''">
<xsl:attribute name="LanguageTagIETF">
<xsl:value-of select="AS:LookupValue('7823d8af-4968-48c3-a772-287475d429e1',@refCustomerLanguageId)"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="string(@refCustomerSalutationId) != ''">
<xsl:attribute name="Salutation">
<xsl:value-of select="AS:LookupValue('67d3131e-a81d-462d-830c-b67fdb2d6bb8', @refCustomerSalutationId)"/>
</xsl:attribute>
</xsl:if>
</AsapNotificationContact>
</xsl:template>
</xsl:stylesheet>
AsapNotificationContact entity Description
Name | Mandatory | Description |
ContactIdentification | x | Identification of a contact. Email in case of e-mail notification channel, phone number in case of SMS channel, etc. |
Name | Name of contact (e.g. FirstName and Name, or just Name). | |
LanguageTagIETF | Language tag, e.g. ‘en-US’ or ‘de-DE’. | |
refSalutationId | Contact salutation identifier (Guid). Useful in a multilingual application. | |
Salutation | Contact salutation (string). |
Example
Example of notification template using generated contacts
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:AS="http://schema.advantages.cz/AsapFunctions"
xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date">
<xsl:param name="RecipientRow" />
<xsl:template match="ROOT">
<ROOT>
<AsapNotification>
<xsl:attribute name="Subject">
<xsl:value-of select="concat('Rental Transaction ', /ROOT/RentalTransaction/@Number,' Booked')"/>
</xsl:attribute>
<Body><html>
<xsl:variable name="salutation">
<xsl:choose>
<xsl:when test="string($RecipientRow/row/@refSalutationId) = ''">
<xsl:value-of select="'Mr/Ms'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="AS:LookupValue('67d3131e-a81d-462d-830c-b67fdb2d6bb8',$RecipientRow/row/@refSalutationId)"/>
</xsl:otherwise>
</xsl:choose>
...