Press "Enter" to skip to content

Create QR Codes with Power Automate and Encodian

We’ve recently released a few new actions for the ‘Encodian connector for Power Automate‘ and this post focusses on the ‘Create QR Code‘ action.

QR codes are typically used to store an encoded URL or short string value within an image which can be read natively by most smartphone cameras, for further information check out Wikipedia.

This post outlines two ways of creating a QR code and embedding within a document;

  1. Add the QR Code image as an ‘Image Watermark
  2. Add the QR Code to an HTML template as a DataUri

Add QR Code as an Image Watermark

For this example we’ll add a QR Code to PDF when document when is it updated and its metdata meets a defined criteria. The QR Code will encode a URL value taken from the URL metadata field associated with the document. Skip steps 1 > 5 if you simply want to review how to generate the QR code and add to an existing document using a watermark action.

1. Create a new Flow using the ‘Automated — from blank‘ option

2. Enter a name for the Flow, select the ‘When a file is created or modified (properties only)‘ SharePoint trigger action and click ‘Create

3. Configure the SharePoint trigger action:

3.a. Site Address: Enter the location of the target SharePoint site

3.b. Library Name: Select the target SharePoint document library

3.c. Folder: (Optional) Select the target SharePoint folder

4. Next, let’s add the following trigger conditions to the trigger action to ensure the Flow is only triggered for PDF documents where the ‘URL’ metadata field contains a value and where a QR code has not already been added.

4.a. On the SharePoint trigger action, click ‘‘ and then ‘Settings

4.b. Underneath ‘Trigger Conditions‘, add the following conditions:

This Flow will overwrite the same document which the trigger is raised from, therefor we need to add a mechanism to stop the Flow continually re-triggering itself. I have added a ‘QR Code Added’ metadata column to the SharePoint library which will be set within the Flow, the trigger conditions below will prevent event recursion by filtering any events where the ‘QR Code Added’ value is true.

  • Only PDF Files: @endsWith(triggerBody()?[‘{FilenameWithExtension}’],’.pdf’)
  • URL field contains a value: @not(empty(triggerBody()?[‘URL’]))
  • QR Code Added field is not true: @not(equals(triggerBody()?[‘QRCodeAdded’],true))

5. Add a ‘Get file content‘ SharePoint action

5.a. Site Address: As per step 3.a

5.b. File Identifier: Select the ‘Identifier‘ property from the SharePoint trigger action

6. Add a ‘Create QR Code‘ Encodian action

6.a. Barcode Data: Select the ‘URL’ property from the SharePoint trigger action

6.b. Image Format: Select ‘PNG

7. Add a ‘Add Image Watermark (Advanced)‘ Encodian action

7.a. Filename: Select the ‘File name with Extension’ property from the SharePoint trigger action

7.b. File Content: Select the ‘File Content’ property from the SharePoint ‘Get file content‘ action

7.c. Watermark Filename: Select the ‘Filename’ property from the ‘Create QR Code‘ Encodian action

7.d. Watermark File Content: elect the ‘File Content’ property from the ‘Create QR Code‘ Encodian action

7.e. Watermark Opacity: Set to ‘1

7. Add an ‘Update file properties‘ SharePoint action

7.a. Site Address: As per step 3.a

7 .b. Library Name: As per step 3.b

7.c. Id: Select the ‘ID‘ property from the SharePoint trigger action

7.d. QR Code Added: Select ‘Yes

8. Add an ‘Update file‘ SharePoint action

8.a. Site Address: As per step 3.a

8.b. File Identifier: Select the ‘Identifier‘ property from the SharePoint trigger action

8.c. File Content: Select the ‘File Content‘ property from the ‘Add Image Watermark (Advanced)‘ action.

9. The completed flow should follow this construct:

Test the flow by adding a PDF document to the target library ensuring relevant metadata fields are set to ensure the trigger actions operate correctly.

The QR code should have been added to the document:

10. (Optional) Apply additional configuration to the ‘Create QR Code‘ action to alter the colours and size of the QR code image:

11. (Optional) Apply additional configuration to the ‘Add Image Watermark (Advanced)‘ action to place the QR code image in a specific location(s) within the document.

The revised configuration example:

Add a QR Code to HTML as a DataURI

Given this post is already quite long! we’ll provide a simple example for embedding a QR Code into HTML which could either be sent in an email or converted to a PDF or Word document. This example converts HTML into a Microsoft Word document using the Encodian ‘Convert HTML to Word‘ action

1. Create a new Flow using the ‘Instant — from blank‘ option

2. Enter a name for the Flow, select the ‘Manually trigger a flow‘ trigger action and click ‘Create

3. Add a ‘Create QR Code‘ Encodian action

3.a. Barcode Data: Enter a value

3.b. Image Format: Select ‘PNG

To embed the image into HTML we need to convert the ‘File Content‘ property (the QR code image in Base64 format) into a DataURI.

4. Add a ‘Compose‘ action

4.b. Inputs: Enter the following expression

 dataUri(base64ToBinary(body('Create_QR_Code')?['FileContent'])) 

5. Add a ‘Convert HTML to Word‘ Encodian action

5.a Filename: Provide a name for the new Microsoft Word file

5.b. HTML Data: Enter the HTML Data to convert to Microsoft Word format

5.c. Select the ‘Outputs‘ property from the Compose action and add within the ‘src‘ property of the target HTML img tag.

6. Add a ‘Create file‘ SharePoint action

6.a. Site Address: Enter the target SharePoint sites URL

6.b Folder Path: Select the target SharePoint library path

6.c. File Name: Select the ‘Filename‘ property from the Encodian ‘Convert HTML to Word‘ action

6.d. File Content: Select the ‘File Content‘ property from the Encodian ‘Convert HTML to Word‘ action

7. The completed flow should follow this construct:

Execute the Flow and check the file has been created with the QR code embedded:

Finally…

The ‘QR Code‘ action simply returns an image and therefore you can use any of the capabilities Flow to work with the QR code.

We hope you’ve found this guide useful, and as ever, please share any feedback or comments – all are welcome!

5 Comments

  1. TK TK

    Hi Jay

    This is very interesting and helpful.

    Can I ask you, I am trying to use the QR code from MS Form to capture attendance check in intot SharePoint list and when the person submit the MS Form, a auto thank you message from the form will be send to them or shows up.

    Is there a way not to show the auto Thank You message and use workflow to create a customize thank message with a link for the registered person to click that will link to eg a ZOOM meeting

    Thank you

    • Jay Goodison Jay Goodison

      Hi, I’m sorry but I’m not following your question, its not clear what you’re trying to do. You can use Flow to send a custom email post form submission and you can change the default message on the form, but you cannot customise the default message with dynamic data. HTH Jay

  2. Alex Alex

    is there a possible way to create a qr code that can trigger more than action, for example, scan the qr code then connect with the with wifi first and go to a specific URL.

    • Jay Goodison Jay Goodison

      Hi Alex,
      A QR code like any barcode stores data… reading the QR Code / Barcode simply provides the data encoded in the image. If you needed to perform actions you would need to do this with an external solution like Power Automate… if you need to add multiple values to a QR Code / Barcode consider encoding your values as JSON and using this to create your QR Code / Barcode.
      HTH
      Jay

Leave a Reply

Your email address will not be published. Required fields are marked *