Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

HTML Table to JSON Array Resulting in Duplicated Data

(0) ShareShare
ReportReport
Posted on by 2

Hello all! Hoping someone can help me figure out where the issue is in my flow.

 

The flow grabs data from an HTML table embedded within an email, converts it to a JSON array which is then parsed so that I can populate specific values into List entries.

 

I've been able to successfully convert the table and populate the values into the list, but for some reason, it is duplicating values so that instead of one new item added to the list there are four new items. 

 

Here are the flow actions which happen once an email is received. Expression details are below

mbarron486_0-1686231418309.png

 

CompostTableStart - substring(triggerOutputs()?['body/body'], indexof(triggerOutputs()?['body/body'], '<table'))

ComposeTableEnd - substring(outputs('ComposeTableStart'),0,indexof(outputs('ComposeTableStart'),'</table>'))

ComposeAddCloseTableTag - output of CompostTableEnd </table>>

ComposeHTML - xml(replace(outputs('ComposeAddCloseTableTag'), '</colgroup>','</col></colgroup>'))

ComposeCountRowsMinusOne - int(xpath(outputs('ComposeHTML'), 'count(//tr)'))

SelectRowsFromHTML 

  • From - range(2,outputs('ComposeCountRowsMinusOne'))
  • Map:
    • First Name - xpath(xml(outputs('ComposeHTML')), concat('//table[1]//tr[1]/td[2]/text()'))?[0]
    • Last Name - xpath(xml(outputs('ComposeHTML')), concat('//table[1]//tr[2]/td[2]/text()'))?[0]
    • Phone Number - xpath(xml(outputs('ComposeHTML')), concat('//table[1]//tr[3]/td[2]/text()'))?[0]
    • ZIP Code - xpath(xml(outputs('ComposeHTML')), '//table[1]//tr[4]/td[2]/text()')?[0]

Parson JSON

  • Output of SelectRowsFromHTML
  • Schema: 
    {
        "type""array",
        "items": {
            "type""object",
            "properties": {
                "First Name": {
                    "type""string"
                },
                "Last Name": {
                    "type""string"
                },
                "Phone Number": {
                    "type""string"
                },
                "ZIP Code": {
                    "type""string"
                }
            },
            "required": [
                "First Name",
                "Last Name",
                "Phone Number",
                "ZIP Code"
            ]
        }
    }

I'm fairly certain the issue is happening somewhere in the ComposeHTML and SelectRowsFromHTML actions because I can see in the Outputs for SelectRowsFromHTML what appears to be the duplicated data:

mbarron486_1-1686232020991.png

Any thoughts for suggestions are appreciated!

  • FGirardi Profile Picture
    FGirardi 14 on at
    Re: HTML Table to JSON Array Resulting in Duplicated Data

    Hello @mbarron486,

     

    Do you mind to share each configuration of composes until parse it to Jason? I'm facing trouble to convert an HTML text from email to JSON.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard