Search code examples
htmlonedrivepowerappspower-automate

How to add dynamic data in an HTML document via a Power Automate flow?


I'm working on a flow to take data from a SharePoint list, and add it to a specific point in HTML. I am just saving the outputted HTML file to my OneDrive whilst testing.

I have found that when pasting my HTML code into a compose block, then outputting this, it works fine and I'm left with a normal looking HTML page when opened in a browser.

However, as soon as I add dynamic data in place of certain HTML elements it all seems to go wrong.

Firstly, the outputted HTML file now contains '/n' in place of every line break. I have also noticed that the outputted HTML code has now been changed to an array.

I've attached screenshots of my flow below.

Get Items: enter image description here

Compose: enter image description here

Create File: enter image description here

Create File Peek Code: enter image description here

Compose Output: enter image description here

Create Output: enter image description here

Create Output Raw: enter image description here

Outputted HTML File: enter image description here


Solution

  • Are you processing the output from that Compose action?

    What you are doing is correct and it would not matter if you are using a single or multiple lines of text.

    It seems to me that you are using the output of the compose somewhere else or maybe the file content box in the OneDrive action has an expression?

    Please check the following:

    1. The output of the compose should look normally

    2. Make sure your OneDrive's action parameters look like this when you "Peek code" (Click on the action's ellipses). If it looks different, you'll have to track the variable/output you are using or review the expression.

      OneDrive Peek Code

    I have replicated what you are doing and it is working fine, see attached images.

    Edit mode:

    Compose HTML and save to OneDrive

    Run:

    Compose action

    Compose action

    OneDrive action

    OneDrive action

    Created File in OneDrive:

    Created File

    EDIT: Update response to use the result from SharePoint in two different ways.

    1. Use the OneDrive action inside the 'Apply to each' if there is only 1 result, it will run once anyway.

    2. You can omit the 'Apply to each' action using the expression box to set the values in the Compose, this is the syntax you can use.

      outputs('Get_items')?['body']?['value']?[rowIndex]?['ColumnName']

    In case there are several rows in the result, you'll have to validate which is the one you need.