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 customized application and a process that starts automatically once a day. Here you will find a ZIP file with our example, which you can import into a portal as usual.
Modify the application
Reference to users
A reference to the "User" module is created in the data records that are to be combined in a collective mail via the properties dialog of the data group. This provides the UserID, Username and Business email fields.
Modify the edit page
On the input page, the user can be selected from a correspondingly configured selection list.
Data field for email send date
Now a data field is required - in this example the data field "Sent on" with the data type "Datetime". This field will not be linked to an edit element. It will only be populated with values by the process.
Create the view page
Now a view page (here, for example, the page "tbl_Details") is created, which displays the desired data of a single data record (here a task). This page can be provided with a button that a user can use to open the task later from the collective e-mail.
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 this example, we implement this with a freely designed table on a view page (here the "Collective mail" page in the first level of the application structure. The view page "tbl_Details" is included in the properties dialog of the table.
Filter
In our example, the second condition excludes all tasks that have not been completed (Completed = false). This status is entered using the checkbox on the input page. The first condition is interesting (Ref. Users - User ID = 'int_UserId'). Here, 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 must be created here with an OR link. 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 reacts to the global timer.
Groovy Script Action
With the timer event handler, the Groovy action "Assemble addressees" 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 set is read out. The variable is made available with g_sharedState in the processing context.
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 is created with an OR link. 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 included in the e-mail action. In this process step, Intrexx uses the variable "int_UserId" created in the Groovy action to filter the table on the included page. The table filter created in the application is automatically applied before the page 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
In the field mapping, a user-defined value is created that 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 be configured in Intrexx in order to send emails.