Sep 13, 2019 10:06:19 AM
A request i sometimes see from customers upgrading from NPrinting v16 is the ability to send multiple emails to the same user for the same NPrinting Publish Task.
We can use a 'cycle' to send different filtered copies of the same report in the same email, but sometimes we want those filtered reports to be split by email.
Also, sometimes its not just for one user but a combination of users.
Basically we want to send out the same report filtered different ways for different people in different emails....
The solution in v17+ is to use the API for this request and we can use the Qlik REST Connector inside the load script of a QlikView QVW or a Qlik Sense app to sequentially run the task changing the recipients and filters with each task execution. By changing the recipients and their filters with each task execution, the recipients receive the reports in the task in different emails.
For reference, see the following resource on how to setup a Qlik load script to communicate with the NPrinting API
https://help.qlik.com/en-US/nprinting/April2019/APIs/NP+API/index.html
In the attached sample you will find the following approach
1. Pre-create the Publish Task in NPrinting with the required report(s) and distribute the task to an NPrinting group
In this example the name of the task is "Email Management Reports" . Make a note of it because we will use the name in the Qlik load script so that we can trigger the task by name.
In this example, the task distributes to the NPrinting Group: Managers . Make a note of the Group name since we will use the Qlik script to update the group membership by group name with the list of user's by name
In this example, the users that will be used are called: Jonathan Poole and NPrinting. Make a note of the names as the script will look up these users by name in order to add them to the NPrinting Group and associate them to the filters.
2. Pre-create the filters that you'd like to apply with each task execution
In this example the 3 filters that i'll be using are named: EMEA , ASIA, AMERICAS. Make a note of the name as these filter names will be referenced by the load script which will dynamically associate the filters by name to the user's by name.
3. Edit the load script to load the NP Users and NP Filters that you want applied to each task execution. Each record of the LOAD represents a different execution
In this example recall that the Task was named "Email Management Reports" and the Group was named "Managers" .
Note that you will also have to update the NPrinting server URL, the QlikView Server (from where you are running the load script) as well as the two REST connections to GET and POST requests to the NPrinting API respectively
4. Next is to LOAD the recipient/filter combinations you would like to apply to the NPrinting Publish Task for each iteration:
In this example the task will be executed 3 times , once per record.
The 1st execution will send the report to the user named: NPrinting with the filter: ASIAPAC
The 2nd execution will send the report to the user named: Jonathan Poole with the filter: EMEA
The 3rd execution will send the report to the user named: Jonathan Poole with the filter: AMERICAS
In summary - NPrinting will get the report filtered by the Region=ASIAPAC in 1 email while Jonathan Poole will get two distinct emails.. .one filtering the report by EMEA , the other by AMERICAS
5. There is a summary of the executions presented to the user upon completion
Hi Jonny,
Thank you for this wonderfull, well explained article!
I implemented it completely and it works great except one thing:
The Nprinting task is triggered from the QS application and marked completed in Task execution window but no email is sent (in the Log part of the Task executions only one line is appear- "Plan branch execution completed").
Of course when I run the publish task manually from the Nprinting with a given user, the email is sent. Also I gave a role to the users in your example.
Do you have any recommandation where should I look?
Two answers:
1. check the NP Console -> task executions to see if the execution was ever kicked off ? If YES , what are the details ? click the execution to see the details
2. there is a newer easier to use feature for this in April 2020. You can now add extra 'TO' email addresses for each recipient delivery. NPrinting sends unique emails directly to each recipient . So a task with two recipients will send discreate emails to each recipient. But now you can add a dynamic user property or vairable to the 'extra TO' , which can resolve to 1 or more extra emails for EACH recipient delivery, so that dynamically you can add extra email addresses to the email when its sent. The recipient is still the driver of the user filter and actual email
Hi Jonny!
Thanks for this great post.
I have exactly the requirement you've described: I have a report which runs with a "Customer" cycle. Some of the people that receive the report has one customer, but others have many and they receive only one mail with all the reports inside a .zip file (something they dislike very much)
What the users want is to receive one email with one customer report each. For example Pao@email.com has to receive one email for the customer A and one for the customer B (sometimes there might be 9 or more different reports to the same user, the number is variable) and Cande@email.com has to receive Customer C and Customer D.
Which dummy adresses might be configured to adress the desired behaviour if the ones that are real for NPrinting are Pao@ and Cande@?
Thanks in advance for your help.
Cecilia.
Hi,
For optimization reasons, Qlik NPrinting will create always a single email for each user in a single task. The only way to send two email to the same recipients is to create them from two different tasks. I think it is not feasible if you have a big or dynamic number of emails for each user.
Best Regards,
Ruggero
Thanks for your reply, Ruggero!
Do you think that using the API as Jonny explained can be at least a work-arround? Can you share your thoughts about Pros and Cons?
Best regards,
Cecilia.
Hi,
I agree with Jonny. If you follow his suggestion be aware of this issue https://community.qlik.com/t5/Qlik-NPrinting-Discussions/Nprinting-REST-API-broke-after-June-2020-up... that is under resolution.
If you are using a recent version (April 2020 or newer) that supports alternate email explained in https://help.qlik.com/en-US/nprinting/June2020/Content/NPrinting/DistributionSchedulesAutomation/Dis... you could create two users for pao@email.com with two distinct prymary emails but with the same alternate email 1 (for example). To each user you associate a different filter and add both as recipients of the task. I have not tested but this should help without the need of developing with API.
Best Regards,
Ruggero
I think @ccaporaso the issue is that your using a cycle. Its a great feature but it does ZIP everything always. There are many requests for an option to not ZIP but a new setting isn't imminent.
It could be possible to restructure your task so that you have one recipient for each value in the cycle. That way you get one email for each value.
Then add qlik variables that resolve to a delimitted list of email addresses that should get the email for that region. To make the variable dynamic you have to add user filters to each one of these "recipients" so that the list of email addresses that are added to the To or CC or Bcc changes for each recipient.
Its manual and indirect but it would do the job. Instead of a recipient getting one email with 5 reports zipped together. They would get 5 different emails with one report attached unzipped (unless its html attached). Also this feature (additional To, CC, bcc) makes those email addresses appear in the email the user receives, so its not a personal direct email but a 'group' email .