cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nide0006
New Member

Flow Issues - Thank You In Advance!

Hi All -

 

I am trying to trigger an email on a weekly basis via a SharePoint list. I have a similar email that works flawlessly but I'm having issues with this one. I think the root cause is that some items in the SharePoint list are multi-select. I want the outputs to still show up in the table though. This is what I am seeing:

 

You'll note the text comes out very funky. No idea how to fix. 

 

nide0006_0-1670279073972.png

My Flow is:

 

nide0006_1-1670279109082.pngnide0006_2-1670279129631.pngnide0006_3-1670279144064.png

the details are: 

replace(replace(replace(replace(replace(body('Create_HTML_Table'), '&lt;',  '<'),  '&gt;',  '>'),  '&amp;''&'),  '&#39;',  '"'), 'quot;','"'

 

nide0006_5-1670279221238.png

Details are:

<style>
table {
border: 1px solid #1C6EA4;
background-color: #EEEEEE;
width: 120%;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid #AAAAAA;
padding: 3px 2px;
}
table tbody td {
font-size: 12px;
}
table thead {
background: #1C6EA4;
border-bottom: 2px solid #444444;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: #FFFFFF;
border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
border-left: none;
}
</style>

 

nide0006_6-1670279278118.png

 

Any idea how to fix this? I am not an expert but have watched multiple videos. I'd appreciate clear steps that a beginner can follow. Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @nide0006 ,

 

I've made a test for your reference:

1\My SP List

vbofengmsft_0-1670290521752.png

2\My Flow

vbofengmsft_1-1670290562089.pngvbofengmsft_2-1670290594786.png

vbofengmsft_3-1670290608940.png

3\Result

vbofengmsft_4-1670290666013.png

 

Best Regards,

Bof

 

 

 

 

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @nide0006 ,

 

I've made a test for your reference:

1\My SP List

vbofengmsft_0-1670290521752.png

2\My Flow

vbofengmsft_1-1670290562089.pngvbofengmsft_2-1670290594786.png

vbofengmsft_3-1670290608940.png

3\Result

vbofengmsft_4-1670290666013.png

 

Best Regards,

Bof

 

 

 

 

grantjenkins
Community Champion
Community Champion

This sort of scenario is perfect for XML and XPath to get what you want, and to avoid using loops making it much more efficient.

 

Below is the List I'm using for this example. Note that it has multi-select Choice (Countries) and Person (Members) columns.

grantjenkins_1-1670335254928.png

 

See full flow below. I'll go into each of the actions.

grantjenkins_0-1670335152007.png

 

Get items retrieves all the items from our list.

grantjenkins_2-1670335306874.png

 

XML is a Compose that converts our JSON output from Get items to XML. Note that the expression also adds a root element to ensure it's valid XML. The expression used is below. Getting our data into XML means we can use XPath in the next step to collate values across rows.

xml(json(concat('{"root": { value:', outputs('Get_items')?['body/value'], '}}')))

grantjenkins_3-1670335375669.png

 

Below is a sample of what the list data would look like in XML.

grantjenkins_4-1670335457857.png

 

Create HTML table uses XPath expressions to build up our table.

grantjenkins_5-1670335506617.png

 

The expression we use as the input (From) data is below. Effectively, it's getting the value property from our XML which is our array of items.

xpath(outputs('XML'), '//root/value')

 

The Title and Description values are Single line of text columns so we can use the following expressions to get these.

xpath(item(), 'string(//Title/text())')

xpath(item(), 'string(//Description/text())')

 

Status is a single select Choice column, so we also need to add /Value to get the actual value.

xpath(item(), 'string(//Status/Value/text())')

 

Countries is a multi select Choice column, so we first need to get the collection of Countries including the /Value, then join them with ', '.

join(xpath(item(), '//Countries/Value/text()'), ', ')

 

Members is a multi select Person column, so we first need to get the collection of Members including /DisplayName to get the actual name of the person, then join them with ', '

join(xpath(item(), '//Members/DisplayName/text()'), ', ')

 

This gives us our HTML table with all our data.

 

CSS is a Compose which is the same as yours, to style the HTML table.

grantjenkins_6-1670336143876.png

 

And finally, adding the Table including CSS to our email.

grantjenkins_7-1670336182643.png

 

And the output of the email.

grantjenkins_8-1670337056678.png

 



----------------------------------------------------------------------

If I've answered your question, please mark the post as Solved.

If you like my response, please consider giving it a Thumbs Up.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,793)