How to create an HTML table using Power Automate (Flow) in mail

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] I received lots of requests from my students and my YouTube viewers on how to create an email that contains an HTML table so today we are going to get into it it's not complex as long as you know how to work with expressions so let's put the simple scenario together and do it in this video I want to show you how to create a table like this and send it by email and this email should come from power automate to make it a little bit more interesting I want to get all that information from a list inside SharePoint so there is a list inside SharePoint that has all these values and we want to extract these values using power automate and send it by email in a table sounds interesting tel let's do it but before we get there for all my students who have taken my power automate expressions in to our sports on udemy this shouldn't be much probably you may have only one action as something new that converts JSON to HTML table everything else you should teach me not me teaching you so although I know you know most of this you may want to bear with me to the end of this so buckle up everybody because we want to get into a little bit of expression writing this is our approach we want to get items from a SharePoint list using get items something that everybody knows convert the items to simplify JSON format using select so basically if we get a complex JSON from here and convert it to something that matches this table then we use the create HTML table action to convert or JSON file to an HTML table and finally we send by email before we do anything let's go to SharePoint and see our list inside my SharePoint site you see I have a list called PR d01 if I click on this you will see the list of items inside it so I have title category unit price and ID I'm using this list because category is actually a lookup field from another table and I just decided to use this list to add a little bit of more complexity to cover all the scenarios and see how useful the expressions can be when you're working with power automate so we want to convert this to a table inside an email let's get to flow and start to work so just like before I go to flow at Microsoft calm and I click on create I want to create a simple flow using a button so instant flow and I want to call it HTML email table demo then I click on manually trigger a flow and I click on create so basically a flow that when someone clicks on a button it starts to work first step was supposed to be get items from a SharePoint list using get items so we go back to flow and I click on menu step and I use SharePoint click on SharePoint and I use kit items all right click on get items and this get items should get the list items from the PRD 0 1 just like before I pick up the URL of the site I go back to flow and I click on the drop down even if it is there I want to click on the custom value and I just want to copy and paste the URL of the site here then it's time to pick up the list that I want to get the values from so I click on the drop down list and the list that I have is PRD 0 1 remember PR d01 is the list that I'm working with I just picked up the site address and a listing did we get everything let me just save it and make sure that the first step is successful so I click on test and I test it save and test I click on confirm run flow done and let's see the output of this gate items if I expand it and I scroll down you will see the body has a value and this value is an array of all the list items in JSON but it's a little bit complex because it contains everything because I need to get back and work with this JSON structure in my expressions I'd rather get a copy of it and I want to put it somewhere in a notepad file notepad and I just paste the list here and we can examine it here easily let me just go to the top of the page so this is a JSON object it has one property called value and inside this value I have an array that every single element is actually a list item so we have the ID we have the title we have category which is a little bit complex we just need the values of it to put it in the email and we also have the unit price perfect I just keep it the way it is so we are done with the first task which is get items from a SharePoint list using n items let's go to that next step which is convert items just simplify JSON format using select as you can see we have a complex JSON here with lots of unnecessary content that is not going to help us frame you're going to create a table we need to match the JSON file with the table structure to do that we use the Select action let me get back to power automate I click on edit and the next step is using select select is one of the data operation actions so if I click on data operations you'll find select here there are a few of them that in my expression course I'd cover all of them here I'm using this select select is very simple select actually accepts a complex JSON and converts it into another JSON format it doesn't mean the output is going to be simpler it can be more complex it can be simpler at the moment we just want to simplify and we want to extract only the values that we need from the get items so remember this one we need the value of this output so let me get back here and under get items I go to select and from the get items if I scroll down I will find the value if I click on the value all this JSON content from here which is basically a JSON array comes to this action from now on my job is to construct a new JSON object and this JSON object should have my title as the first element which will eventually make my table column this title should come from this value if I want to get the title of the value I need to go to the expression and I use the function item item is a power automate expression that when I'm dealing with the array item returns the current item of the array that I'm working with so for the first item that I am processing it's going to look into my floppy disk with the id3 so I have this item now I need the title of this item the field that I need from here is title copy I just paste it here so item dot title and I click on OK I have the title here second one I go back again there and I see what I need to add for the second one let's add the ID here too so I go to the ID and here I go to the expression and I say again item opening and closing bracket by D and again I click on OK this cell can add more but just for now let me test this and make sure I'm getting what I'm asking for so I could contest save and test I perform the action again and I click on done job is done so here again getitem has this complex array but select has this simplified output so I have title and I have ID great I just need to add a little bit more information and you are all good so let me click on edit the other field that I need is going to be category category is a little bit more complex let's see how we do it so I say category and here again I go to the expression I get the item now category is not a direct value so if I come here under value I have category dot value I don't need the category and the content inside it as an object I need the specific property of this category called value so what I need here is going to be item category dot Valley so I'm good let's click on OK save and examine it one more time because this is where we are supposed to make mistakes I hope not so done if I click on select now the output contains title ID and category fantastic I got what I wanted do we need anything else sure you also need the unit price which looks like this here but we can simplify it and make it a little bit better on our flow so instead of that weird headline I can say unit price and because it's adjacent property I can even have a space in it so it looks really good when I convert it to a table I click on here and for this one I click on expression I say item bracket dot and I put that weird field called unit price with this space that is converted to this code I click on OK and we're all good is there anything else I want to bring in if I want to do no problem I can simply pick up for example if even if the even even if I want the author I can put the display name here you want to do that let's do it let's say create it by and for this one again I go to expression I'm writing item but you remember the field name author copy and paste exactly as is dot and under I want display name so I pick this one and I copy and paste it here so for the item for the created my I have item dot author dot display name I click on OK again and I click on save fantastic so we cut all the items in a complex JSON and be converted to a flat simplified JSON array that I can directly convert it into an HTML table let's test it and make sure it works as expected done if I expand the select you will see I have everything here title ID category unit rice and created mine we are done with converting items to simplify JSON format using select now we need to convert this JSON to an HTML table using Create HTML table so new step create HTML table let's scroll down create HTML table is another data operation I click on it and under create HTML table I get the content from this select because select creates my simplified JSON object and this JSON object is an array so basically when I pass an array of objects in JSON to create HTML table action it returns a table for me so let me get the output from select you want to test it now let's test it save and test run flow done and now this one receives this JSON and the returns this table isn't that beautiful and I think there is not much to say you just need to add this newly created HTML table to an email body and send so I click on new step to send my email and I select send email scroll down send an email and I want to send it to myself I don't send it to over you want subject is going to be list of products in a bracket PR d01 and the body you can add any header that you want hello this is the product list you asked for and right under it I can add the output from create HTML table let me click on output right click on save and this is the very last step of this process let's test it save test save and test and I click on continue run flow done now let's go to my mailbox and see the result and here is a list of products in my mailbox and that was all about it if you already taken my course about poor automated expressions I want to know your feedback and I want to see how close you could get to this scenario after finishing that horse regardless thank you for watching and stay tuned till the next video [Music]
Info
Channel: Alireza Aliabadi
Views: 28,104
Rating: undefined out of 5
Keywords: create HTML table using Power Automate, power automate how to, send email, html email, microsoft flow tutorial, microsoft flow sharepoint, microsoft flow email, power automate tutorial, create html table useing power automate, create html table using pwoer automate, create html table useing pwoer automate
Id: 37g5rkLlkmE
Channel Id: undefined
Length: 17min 35sec (1055 seconds)
Published: Sun Jun 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.