cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Add JSON sub-array to email

Hi,
I have a JSON which is feeded from PowerApps and consists of a number of values and strings as wells as an array from a powerapps gallery. The schema has the arrays at the bottom, called Product and Version.

 

 

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "CSM": {
                "type": "string"
            },
            "PP": {
                "type": "string"
            },
            "EngStat": {
                "type": "string"
            },
            "KeyAch": {
                "type": "string"
            },
            "MFR": {
                "type": [
                    "number",
                    "null"
                ]
            },
            "Name": {
                "type": "string"
            },
            "CurrentUserMail": {
                "type": "string"
            },
            "Portfolio": {
                "type": "string"
            },
            "QCCR": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RelStat": {
                "type": "string"
            },
            "Rev19": {
                "type": [
                    "number",
                    "null"
                ]
            },
            "Support": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "Tier": {
                "type": "string"
            },
            "Version": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "Current_x0020_Product_x0020_Vers": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "Current_x0020_Product_x0020_Vers"
                    ]
                }
            },
            "Product": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "Product": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "required": [
            "CSM",
            "CurrentUserMail",
            "EngStat",
            "Name",
            "PP",
            "Portfolio",
            "Product",
            "RelStat",
            "Tier"
        ]
    }
}

 

 

 

I am building a html email with JSON regular fields added, which works fine.

However I also want to add both (complete) Product and Version arrays to the email. Once I add Product as dynamic contents Flow will add an "Apply to each" and this is not what I want. Actually this sends out n mails, with n the size of the array 😉

I'd like to have the whole contents of the arrays added to the mail at once. The size of the array is not constant, but may vary from 1 to 10.

Any help appreciated!
Thanks

Stefan

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Hi again!
Try with the following

body('Create_HTML_Table_Versions')


For some reason, the new UI version rolled out at the beggining of this week, is mucho more restrictive when showing dynamic content options
If you need to change HTML table format (css etc) please let us know
Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

8 REPLIES 8
Highlighted
Dual Super User III
Dual Super User III

Hi!
Did you consider to use 'Create HTML table' action block and assign as its input the array you wanna show in your email? Then just need to add 'Create HTML table' output in the email body.

So as you have two arrays (Product and Version), you need to add two 'Create HTML table' action blocks

Hope this helps


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted

thanks, good hint, looks I get the data into proper format

 

Version tableVersion table

 

However, and that appears so often, after save & test run, the new tables do not show up in dynamic content. 
Do you know how to refrence them via expressions?
I tried simply
body('Create HTML Table Versions')
but that gives an error in Flow Checker.
Correct to include a valid reference....


Do you have any advice?

Highlighted
Dual Super User III
Dual Super User III

Hi again!
Try with the following

body('Create_HTML_Table_Versions')


For some reason, the new UI version rolled out at the beggining of this week, is mucho more restrictive when showing dynamic content options
If you need to change HTML table format (css etc) please let us know
Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted

yes, thats it, thanks a lot, I will mark the question as solved!

Still one more question on formating the output, my mail now contains

[" 
Product
Product A
Product B
Product C
"] [" 
Current Version
4.7
4.4
9.1
"] 

including [...] and "...".

 

Would you know how to get rid of those as well?

Highlighted
Dual Super User III
Dual Super User III

Hi!

It looks like you are adding the array directly to the email body, instead of the 'Create HTML table' outputs.

I mean an array is a list of elements wrapped inside characters [ and ]. If elements are string, they are also wrapped inside doublequotes:

["Apple", "Lemon", "Orange"]

 

So it looks lika a couple of arrays with one single element inside

Can you share a screenshot from your current flow design?

 

BTW, thanx for marking this topic as solved.

This way other community members facing this same problem in the future have the chance to find a solution faster.

 

Thanx for your contribution to keep this community great!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted

Hi,

Here's the overview of my flow pieces

 

Overview.JPG

 

Create the 2 html tables, getting Product and Version as dynamic content from JSON part

 

create tablescreate tables

 

bottom of html mail

 

htmlMail.JPG

 

For the 2 bodies I simply used your suggested expressions

 

body('Create_HTML_Table_Product')
body('Create_HTML_Table_Version')

 

This results in a mail with the correct details but in the above mentioned format.

 

If you have a new suggestion let me know.

thanks!

 

 

 

 

 

Highlighted
Dual Super User III
Dual Super User III

@Stefan68 

Weird...

Please inspect both 'Create HTML table' action blocks execution, and doublecheck if their outputs look like this


 

Version tableVersion table

 


If so, i would suggest to add temporarily a new 'Send an email' just for troubleshooting purposes, send this new email to you, add to the body both expressions only, I mean without the rest of the stuff you have in your current 'SEnd an email' body

 

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted

same effect still, while checking the flow html body output of a test run looks formated OK, the mail content is malformated.

This is same for both Product and Version tables.

 

jsonversion.JPG

 

mail looks like

 

mailOutput.JPG

 

HTML mail content

 

<br>["<table><thead><tr><th>Product</th></tr></thead><tbody><tr><td>Product Manager</td></tr><tr><td>Test Manager</td></tr><tr><td>Directory</td></tr></tbody></table>"]
    ["<table><thead><tr><th>Current_x0020_Product_x0020_Vers</th></tr></thead><tbody><tr><td>4.7</td></tr><tr><td>4.4</td></tr><tr><td>9.1</td></tr></tbody></table>"]

 

which indeed contains what the mail shows, incl backets [ ]

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (7,243)