In this article:
Example of Unit to Set Up Dynamic Recipient List
To set up task execution result handling options, use the Result page/tab in the task setup wizard.
The following result handling options are available for all tasks:
Sending a notification by email.
Calling a custom event.
The following additional result handling options are available for regular report calculation task:
Publishing to FTP server.
Printing.
File format.
NOTE. For the report sent by email and/or published to an FTP server the following formats are available: XLSX, XLS, PDF, PNG in the web application; XLSX, XLS, PDF, RTF, HTM, ODS, EMF, PPREPORT in the desktop application.
Sending notifications by email is available only for tasks executed by schedule. When tasks are started manually, messages are not sent.
To set up automatic sending of email notification about task execution, select the Notify by Email checkbox and select the option for adding recipients:
Recipient List. To select a list of emails, users or groups of users to whom the report about task execution will be sent, follow the steps:
In the web application set a list of email addresses, to which notification will be sent, or specify a user or group as follows: @UserName/#Group. Put semicolon after each email, user or group of users.
In the desktop application:
Set a list of email addresses, to which notification will be sent. Put semicolon after each email.
Click the Select button to search security subjects. The Select users and groups dialog box opens.
Dynamic Recipient List. To create a list of recipients by condition, follow the steps:
In the Unit box specify the object containing implementation of the function for handling recipient list.
In the Function drop-down list select the function for handling the recipient list.
NOTE. The list shows only functions with the signature: Function <name>(<param>: IScheduledTask): IArrayList.
To set up email parameters:
In the web application set the parameters:
Subject. Enter short task description as an email subject. If required, select substitution text ht will be displayed as an email subject, using the Templates button:
&[TASK_RESULT] - execution result.
&[TASK_NAME] - task name.
&[TASK_ID] - task identifier.
&[TASK_START] - start time.
&[TASK_FINISH] - completion time.
Message Text. Enter text of notification about task execution result.
After executing the task the notification with specified parameters of email is sent to specified addresses. Notification sending state will be displayed in the container workspace in the Notification column.
IMPORTANT. On setting up email sending the configuration file must contain description of the <HOST> section, otherwise emails will not be sent.
To execute the example, add links to the Collection, Metabase system assemblies.
Public Function GetRecepients(Task: IScheduledTask):IArrayList;
Var
List: IArrayList;
Mb: IMetabase;
MS: IMetabaseSecurity;
SSS: ISecuritySubjects;
SS: ISecuritySubject;
Begin
Mb := Metabaseclass.Active;
MS := MB.Security;
SSS := MS.AllUsers;
// Platform user:
SS := SSS.Item(9);
Select Case (Task.State As Integer)
// Task is executed successfully:
Case 3:
List := New ArrayList.Create;
List.Add("user1@example.com");
List.Add(MS.ResolveSid(SS.Sid));
// Task is executed with error:
Case 4:
List := New ArrayList.Create;
List.Add("user2@example.com");
List.Add(MS.ResolveSid(SS.Sid));
End Select;
Return List;
End Function GetRecepients;
Determine created module in the Module field on the Result tab in the task parameters setting dialog box. Enter GetRecepients in the Function box.
After executing the example, the email to send task execution notification will be determined depending on the current state of executed task.
To set up custom event call after the task calculation, execute the following operations.
Go to the Events and Export page:
In the Call Event drop-down list select the event determined on the Custom Metadata > Events tab in repository parameter settings.
Select the Call Event checkbox on the Result tab.
In the drop-down list select the event determined on the Custom Metadata > Events tab in repository parameter settings.
After task execution a specified custom event is generated. This event will be handled by the tasks with configured execution after custom event.
Additional parameters of result handling are available for the Regular Report Calculation task:
In the web application on the Events and Export page.
In the desktop application on the Result tab.
Task calculation result can be published to FTP server. To do this:
Select the Publish to FTP Server checkbox. It is available only in the desktop application.
Set server address in the input field.
After task execution the report calculation result is published to the specified server.
IMPORTANT. On setting up saving files to FTP server, the configuration file must contain description of the <FTP> section, otherwise the report file is not saved to server.
To print task execution result:
Select the Print checkbox. It is available only in the desktop application.
Specify a printer in the following format: server\printer.
File format and export options can be specified for a report attached to a message and/or published to FTP server:
Select report format in the File Format drop-down list:
PPREPORT file (*.ppreport). It is available only in the desktop application.
EMF File (*.emf). It is available only in the desktop application.
OpenDocument spreadsheet (*.ods). It is available only in the desktop application.
Web page, single file archive (*.htm). It is available only in the desktop application.
RTF document (*.rtf). It is available only in the desktop application.
Image (*.png). It is available only in the web application.
PDF Document (*.pdf).
Excel Workbook 97-2003 (*.xls).
Excel Workbook (*.xlsx).
To set up options for report export to the selected format, click the Export Options button. The Export Options dialog box opens. The dialog box appearance depends on the selected report export format.
After task execution the report calculation result is exported to the specified format.
See also: