“I’ve got an html table in the Multiple lines of text SharePoint column that I’d like to extend, how to add new row using Power Automate?”
If you’re like me using HTML tables to display approval history for SharePoint requests, you maybe got a bit surprised. Something that worked for years didn’t work anymore with the rollout of the new SP lists interface. Instead of showing the history in a readable way, the table broke the whole view.
![Power Automate add row sharepoint html](https://tomriha.com/wp-content/uploads/2024/06/image-26-1024x228.png)
The appending of new rows didn’t really work anymore. How to fix it? What’s the right approach to add new rows to the HTML table without breaking the view?
What went wrong
When you store an HTML table in a SharePoint column, it’ll automatically enclose the table in <div> tags. It’ll add some class at the beginning and close it by the end. You can see it if you go to the HTML view in the Multiple lines of text column (left side below).
![Power Automate add row sharepoint html](https://tomriha.com/wp-content/uploads/2024/06/image-28-1024x687.png)
Using ‘Get item(s)’ to load the item later, it’ll return not only your code, but also the opening and closing <div></div> (right side above). Interestingly enough, it’ll skip the <tbody></tbody> tags SharePoint added, but let’s not be bothered by that for now…
Knowing this, removing the </table> tag to add the new row won’t be enough as it’ll still keep the </div>. That’s where I believe it’s breaking the view, the <div> is closed before the whole table is closed and the new lists experience can’t deal with that.
How to do it properly
You want to keep your HTML table code clean, not only for SharePoint, but for any future use – exports, integrations, etc. That means you must adjust your flow to what you get. If you want to add a new row, you can’t just remove the </table> and add it. You must deal with the </div> too.
That means, before you start adding rows, remove both, </table> and </div>, e.g.
replace(replace(triggerOutputs()?['body/ApprovalHistory'],'</table>',''),'</div>','')
![](https://tomriha.com/wp-content/uploads/2024/06/image-30-1024x273.png)
…add the new row into the table…
![](https://tomriha.com/wp-content/uploads/2024/06/image-29-1024x240.png)
…and when storing it back to SharePoint add the tags back. SharePoint might be able to deal with it even without the tags, but as already said, you want to keep your code clean.
![](https://tomriha.com/wp-content/uploads/2024/06/image-31-1024x596.png)
Fixing the existing tables
Unfortunately, the solution above will deal only with future tables, it won’t fix the existing ones. For those you must add the </div> by yourself, item by item, ideally in a separate flow.
Summary
If you use SharePoint multiple lines of text column to store some complex html, you should make sure that your code is clean. SharePoint will give you some help with that, but if you use Power Automate to build it, e.g. to add row to an HTML table, you’ll have to be more careful. Make sure that you check what you get in the JSON, adjust the process accordingly to deal with all the tags, and you should be fine.