Send a report to a list send-a-report-to-a-list
This use case details how to generate a monthly out-of-the-box Tracking indicators report in PDF format and how to send it to a list of recipients.
The main implementation steps for this use case are:
- Create a list of recipients for this report. Learn more.
- Create a delivery template which creates a new delivery each time the workflow is executed. Learn more.
- Create a workflow which generates the report in PDF format and sends it to the list of recipients. Learn more).
Step 1: Create the recipient list step-1--create-the-recipient-list
To create the list of targeted recipients, follow the steps below:
- Browse to the Profiles and targets tab, click the Lists link.
- Click the Create button.
- Select New list and create a new recipient list for the report to be sent to.
For more on creating lists, refer to this section.
Step 2: Create the delivery template step-2--create-the-delivery-template
To create the delivery template, follow the steps below:
-
Browse to the Resources > Templates > Delivery templates node of the ۶Ƶ Campaign explorer and duplicate the Email delivery built-in template.
For more on creating a delivery template, refer to this section.
-
Enter the template parameters: label, target (the list of previously created recipients), subject and content.
Each time the workflow is executed, the Tracking indicators report is updated as explained in Step 3: Create the workflow).
-
To include the latest version of the report in the delivery, you need to add a Calculated attachment:
-
Click the Attachments link and click the arrow next to the Add button. Select Calculated attachment….
-
In the Type drop-down list, select the latest option: File name is computed during delivery of each message (it may then depend on the recipient profile).
The value entered in the Label field will not appear in the final delivery.
-
In the text zone, enter the access path and name of the file.
note caution CAUTION The path and name must be identical to those entered in the JavaScript code type activity of the workflow, as explained in Step 3: Create the workflow. -
Select the Advanced tab and check Script the name of the file name displayed in the mails sent. In the text zone, enter the name of the attachment in the final delivery.
-
Step 3: Create the workflow step-3--creating-the-workflow
Create the following workflow for this use case.
It uses three activities:
- A Scheduler activity which executes the workflow once a month,
- A JavaScript code activity which generates the report in PDF format,
- A Delivery activity which references the previously created delivery template.
To build this workflow, follow the steps below:
-
Browse to the Administration > Production > Technical workflows node of Campaign exploere and create a new folder to store your workflows.
-
Create a new workflow.
-
Start by adding a Scheduler type activity and configure it so that the workflow executes on the first Monday of the month.
For more on configuring the scheduler, refer to Scheduler.
-
Then add a JavaScript code type activity.
Enter the following code in the edit zone:
code language-sql var reportName = "indicators"; var path = "/tmp/indicators.pdf"; var exportFormat = "PDF"; var reportURL = "<PUT THE URL OF THE REPORT HERE>"; var _ctx = <ctx _context="global" _reportContext="deliveryFeedback" /> var isAdhoc = 0; xtk.report.export(reportName, _ctx, exportFormat, path, isAdhoc);
with the following variables:
-
var reportName: enter the internal name of the report in double quotes. In this case, the internal name of the Tracking indicator report is “deliveryFeedback”.
-
var path: enter the save path of the file (“tmp”), the name you want to give the file (“deliveryFeedback”) and the file extension (“.pdf”). In this case, we have used the internal name as the file name. Values need to be between double quotes and separated by the “+” character.
note caution CAUTION The file must be saved on the server. You must enter the same path and the same name as in the General tab of the edit window for the calculated attachment, as detailed here). -
var exportFormat: enter the export format of the file (“PDF”).
-
var _ctx (context): in this case, we are using the Tracking indicators report in its global context.
-
-
Finish by adding a Delivery activity with the following options:
- Delivery: select New, created from a template, and select the delivery template created previously.
- For the Recipients and Content fields, select Specified in the delivery.
- Action to perform: select Prepare and start.
- Un-check the Generate an outbound transition and Process errors options.
-
Save your changes and start the workflow. The message is sent to the list of recipient every first monday of the month, with the attached report.