Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!

How To: Send message in Microsoft Teams with attached PDF report generated by Qlik Reporting using Qlik Application Automation

cancel
Showing results for 
Search instead for 
Did you mean: 
KatjaK
Employee
Employee

How To: Send message in Microsoft Teams with attached PDF report generated by Qlik Reporting using Qlik Application Automation

Last Update:

Apr 30, 2024 7:37:21 AM

Updated By:

KatjaK

Created date:

Apr 30, 2024 7:37:21 AM

Attachments

This article shows an example how you can configure a Qlik Application Automation workflow to generate a simple report using Qlik Reporting Services and attach it as a PDF file to a message sent in Microsoft Teams channel. The main challenge addressed is the configuration of the necessary Microsoft Sharepoint and Teams blocks. 

Content:

 

Background information

  • You can attach only those files to a Microsoft Teams message, that are already existing in Microsoft Sharepoint. 
  • Behind each Micsoroft Teams channel you can find the respective Sharepoint site, where uploaded channel files are stored.
  • Generated PDF report must be stored in the respective Sharepoint first, before attaching it to the Teams message.

Necessary Automation blocks:

  • Qlik Reporting:
    • Create / Generate report
    • further blocks according to your needs
  • Microsoft Sharepoint:
    • Copy file on Microsoft Sharepoint
    • List items on Drive
  • Microsoft Teams:
    • Send message
  • Other:
    • Variable
    • Condition
    • Exit Loop

 

Create new Application Automation

Create a new automation using one of the provided Qlik Reporting templates: Store a simple multi-page PowerPoint report to Microsoft SharePoint

KatjaK_0-1714373902974.png

Configure Qlik Reporting blocks to generate the report needed. For more information on how to generate a PDF report using Qlik Application Automation please refer to previously posted articles (see links below). 

Here is an example of a simple one-page report: 

KatjaK_1-1714374230044.png

 

Copy generated report to Microsoft Sharepoint

The next step is to configure Microsoft Sharepoint automation block to copy the generated PDF report to the site of your interest. Certain input parameters were already pre-filled by the template, which was used to generate this automation. 

KatjaK_2-1714374426184.png

  • Source file: This is the PDF report that was generated by the preceding Qlik Reporting block
  • Destination Connector: The file should be copied to a Microsoft Sharepoint site
  • Destination Path: The path including the file name of the destination
  • Driveid / siteid: Either one of the ids must be provided for the block to run successfully

 

Find necessary driveid / siteid / itemid

There are several ways to find the relevant information (see links to Microsoft documentation below). This article shows one example way, which you can use.

Let's assume an example scenario, where you want to share the generated PDF report in a teams channel named "My Channel". Under the files tab, you can view the files stored in the Sharepoint attached to your channel. There you can create a new folder, for example named "General", where you will store the generated report files.    

KatjaK_3-1714374968537.png

To find the driveid and siteid of this Sharepoint site, you can use Microsoft Graph Explorer and retrieve the necessary information by executing a chain of API calls.

1. First, you must log in to your Microsoft account:

KatjaK_5-1714375794025.png

 

2. Knowing the name of your Teams channel ("My Channel"), you can start a search for sites with this keyword:

 

 

https://graph.microsoft.com/v1.0/sites?search={Keyword}

 

 

KatjaK_6-1714375913402.png

Looking at the returned id, it seems like several siteids (separated by a comma) were concatenated as the example Sharepoint site contains one or more folders.

Note: this might look different in your scenario, however the returned id parameter is the one, which is required for the next steps. 

 

3. This id parameter can now be used as siteid for the next API call, to find the rest of the relevant information for the target folder ("General").

 

 

https://graph.microsoft.com/v1.0/sites/{siteid}/drive/items/root/children

 

 

KatjaK_8-1714377657404.png

Having found the name of the target folder ("General" in the example scenario), you can copy the relevant information into Qlik Application Automation. As this information will be used across multiple automation blocks, it is recommended to store the ids in the respective variables:

  • Driveid: Take driveid parameter from the response
  • Siteid: Take siteid parameter from the response
  • Itemid: Take the eTag parameter from the response (without brackets)

KatjaK_0-1714378105584.png

 

4. Configure the "Copy File on Microsoft Sharepoint" block using the new variables. Additionally, adjust the destination path to use the folder "General". 

KatjaK_1-1714378289902.png

 

Find the generated report file in Microsoft Sharepoint

Having stored the newly created file in Sharepoint, you must now retrieve the eTag of this file to be able to attach it to a message in Microsoft Teams.

Use the Microsoft Sharepoint automation block "List Items on Drive" to iterate over items in a certain folder and find the newly generated file dynamically. Use the initially created variables Driveid and Itemid as input parameters: 

KatjaK_2-1714378703426.png

Include a "Condition" block into the loop to check, whether the file name corresponds to the name of the generated report you are looking for: 

 

 

if {$.listItemsOnDrive.item.name} = {$.generateReport.path}

 

 

In case you have found the correct file name, store the eTag and webUrl parameters of this file in variables. 

  • FileTag: 

 

 

{substr: {$.listItemsOnDrive.item.eTag}, 1, {subtract: {textlength: {$.listItemsOnDrive.item.eTag}}, 4}}

 

 

  • WebUrl:

 

 

{$.listItemsOnDrive.item.webUrl}

 

 

Exit the loop, as you have already found the necessary information.

 

Send Microsoft Teams message with PDF file attached

Insert a Microsoft Teams automation block "Send Message" at the end of your automation. Use the lookup functionality to define your team and channel id, where the message will be posted. 

KatjaK_3-1714379198977.png

Write the content of your message. Use the following tag in the Content field to insert an attachment into the message. The id of the attachment should be the eTag of the file previously stored in the "FileTag" variable.

 

 

<attachment id="{$.FileTag}"></attachment>

 

 

Define the attachment code as follows: 

  • id: eTag of the file (stored in variable "FileTag")
  • contentUrl: url to the stored file on Sharepoint (stored in variable "webUrl")
  • name: name of the file, that will be shown in the Teams message

 

 

[{"id": "{$.FileTag}",
"contentType": "reference",
"contentUrl": "{$.webUrl}",
"name": "{$.generateReport.path}"
}]

 

 

This is how it might look like in the end: 

KatjaK_4-1714380151039.png

Save the automation and execute it. You will now receive a message in your Teams Channel with the content and attachment you have defined:

KatjaK_5-1714380419701.png

 

Related Content

 

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

Labels (1)
Comments
Torsten_Kohrt
Employee
Employee

Great Work Katja 

Contributors
Version history
Last update:
‎2024-04-30 07:37 AM
Updated by: