Tips & Tricks - Collective mail

In this article, you will learn how to create a collective email instead of several individual emails so that, for example, each employee receives a daily email with all unfinished tasks. This requires a modified application and a process that starts automatically once a day. 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

A reference to the "Users" module is created in the data records that are to be combined in a collective mail by means of 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.

Filters

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.

Process

After the import, the process is initially deactivated. If you want to run and test the example, activate the process.

Global timer

The first element in the process is a global timer that starts the process chain once a 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. In addition, the date data field "Sent on", which was created in the application specifically for this purpose, must not be filled. 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

With the timer event handler, the Groovy action "Compile recipients" is connected to the following script as the third element in the process:

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.

Filter condition

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" must not be filled. 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.

Email action

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 made on the "Manipulation quantity" tab:

Simple filter

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.

Field assignment

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.