cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Splitting an array to string - HTML table

In my flow I initialise a variable, varAttachments, which is an array. The array is made up of URLs of the file attachments from a SharePoint list item (AbsoluteURI).

I want to get all the URLs from the array into their own strings and then reference them in my HTML table.

 

So the array is in the format ["AttachmentURL1", "AttachmentURL2"] and I want "AttachmentURL1" "AttachmentURL2" each as strings. There could be any number of URLs in the array.

 

Once I have those I need to add them to a HTML table as below except that each URL string needs to be wrapped in an <img> tag. What would be the best way for me to do this please?

 

calvares_0-1616769558545.png

 

7 REPLIES 7
Anonymous
Not applicable

Just to give some more information on this. This is how I got my array:

calvares_1-1617027439562.png

 

I get my SharePoint items (odata filtered) and initialise the varAttachments variable. I get the attachments for each of my SharePoint items. I append Absolute URI to varAttachments within an apply to each (body for get attachments). 

 

I've also tried this with varAttachments as a string and it creates one string of the URLs without a separator.

Really what I need to do is separate each of my varAttachments into their own values. Am I missing something really obvious?

 

mahoneypat
Solution Sage
Solution Sage

This article shows one way to do this.

https://faustocapellan.com/2021/01/26/how-to-5-format-links-sent-via-email-in-power-automate/

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi @mahoneypat 

Thanks for the idea. The concat is the right idea of what I need to do, but I'm working with multiple images, so it doesn't help with that.

 

I've now got the images to display in my table (in the body of the email but not the PDF) by setting a string variable, varAttachments, to be a concat of <img src wrapped around items('Apply_to_each')?['AbsoluteUri']. This variable is then just added to the HTML table. However the problem is that this brings all the images into each row, where I'd like it to display only the images applicable to each item. I need for the flow to recognise which attachments apply to which items. Is this at all possible?

rich9203
Frequent Visitor

Hi Calvares .... did you succeed with this?  I have a use case to produce a printable (ideally PDF) report of SharePoint items with attachment images displayed for each item - this could be many images for each SP list item.  Thanks Pete

Anonymous
Not applicable

Yes, I found I had to have a flow to generate the URIs when an item was created or modified then update the item in a 'URI' column. Then when creating your HTML document you just need to reference the URI column.

This is from the first flow:

calvares_0-1639498098434.png

In the append to string variable I've wrapped the uri in a <img src>:

concat('<img src="', outputs('Compose'), '"alt="images" width="100" height="100">  ')

 

Just be mindful that some of the dataURIs can be really long so first make sure the column is for multi lines of text. Secondly, it can be a bit of a memory strain on your SharePoint list if you have many items.

Hope that helps.

rich9203
Frequent Visitor

Many thanks for the update .... does this work for multiple attachments for an item?

Anonymous
Not applicable

Yes I had multiple attachments for each item so that's why I had to take this step. 

Also be aware that if you have lots of images there's a 2MB size limit on the OneDrive convert file to PDF.

I hit issue after issue with this!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,703)