Tips & Tricks - Summary emails
This workshop will demonstrate how to create a summary email instead of sending multiple individual emails so that every employee receives a daily email with a summary of their uncompleted tasks, for example. A modified application and a process are required for this. You can find a ZIP file with our example here. You can import this into your portal as usual.
Modify the application
Reference to users
In the data records, which should be summarized in a summary email, a reference to the User Manager is created via the properties dialog of the data group. This provides the UserID, Username and Business email fields.
Modify the edit page
On the edit page, the user can be selected from a drop-down-list that has been configured accordingly.
Data field for email send date
Now we need a data field - in our example the data field "Sent on" with the datetime data type. This field will not be linked to an edit element. It will only be populated with values by the process.
Create the view page
A view page (such as the "tbl_Details" page in our example) is required to display the required data from a single data record (a task in this case). This page can be provided with a button which the users can use later to open the task from the summary email.
Create a free layout table
A page is required for the summary email that filters the data accordingly and then lists this data in the email. In our example, we add a free layout table to a view page ("Summary email" in this case) on the top level of the application structure. The view page tbl_Details is integrated in the properties dialog of the table.
In our example, the second condition excludes all tasks that have not been completed (Completed = false). This status is recorded using the checkbox on the edit page. The first condition is important (Ref. Users - User ID = 'int_UserId'). The user ID stored in the data record is compared for equality with the variable "int_UserId". from the corresponding process. The system option is set to "processing context" in order for the table filter to be able to process the values of the variables. The variable name (int_UserId) is entered as the value. The table filter cannot be constructed in the normal fashion as the table is not intended for a page in the browser but for a page that will be embedded in an email of any standard email program.
The first element in the process is a global timer that triggers the process once per day. Select the required application and data group - Tasks in this case - on the Data group tab in the properties dialog. Furthermore, the date data field (Sent on) that was created for this purpose in the application must be empty. Furthermore, the date data field (Sent on) that was created for this purpose in the application must be empty. The filter expression needs to be created with an OR connection. The first condition is that the data field contains no value (sent on is undefined). The second part filters the tasks so that every uncompleted task that was sent before 00:00 today will be added again to the summary email.
Timer event handler
The second element in the process is a timer event handler that responds to the global timer.
Groovy Script Action
A Groovy script action (Compile recipients) is connected to the timer event handler as the third element in the process. This contains the following script:
def int_UserId = g_record["29EAEF57FB774606A0F0E81FEAACCE669E6E9345"].value /* datafield Ref. Users - (REF-PK) User ID <integer> */ g_sharedState.int_UserId = int_UserId
The variable "int_UserId" is defined here and the user ID stored in the current data record is read. The variable is made available in the processing context with g_sharedState.
This checks whether the user, who was determined in the previous Grovvy script action, has already received a summary email. The date data field (Sent on) may not contain data. The filter expression needs to be created with an OR connection. The second part defines that every uncompleted task that was sent before 00:00 today will be added again to the summary email.
The view page from the application is integrated into this action. In this process step, Intrexx uses the variable "int_UserId" created in the Groovy Script action to filter the table on the integrated page. The table filter is applied automatically before the email is sent and filters the tasks in the table accordingly.
The recipient is determined from the referenced business email address.
Data group action
The last element in the process chain is a data group action. So that an email is not sent to the responsible employee for every data record, all of their other tasks are provided with todays date, 00:00.
The following settings are applied on the Manipulation quantity tab:
The source and target data group are the same, "Tasks" in our example. The data field, the referenced user (Ref. User - Ref-PK) in our example, is also the same.
A user-defined value is created in the field assignment. This provides today's date, 00:00. The value is then assigned to the data field (Sent on). The process is now completed.
The Email service must have been configured to send emails.