Fill and Sign a Word Document with Power Apps and Power Automate without using any premium actions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello again power platform people welcome to another video in this video i am going to show you how you can create and fill a word document directly from powerapps via a flow without having to use any premium actions whatsoever so i will start by showing you a demonstration of what it does and then i'll go into how it does it so i have got this simple power app here and i will type my name in and sign it let's try that again okay so i'll submit that and then i've got a sharepoint folder here in which that document should land any moment let's just go and have a look at the flow is executing now the file is just turned up so let's open that up and that is our document the date has been filled in my name and then my signature has been thrown in as well so let's have a look at how it is done so the first thing i've done is created a word document with my template in it effectively um here's the three fields and notice that the fields are quite particular i've given them some kind of unique identifier date one two three four five to make it easy to find when you put in your unique identifier make sure that you have it all in lowercase or all in uppercase i'll explain why in a moment but um it just makes it easier to find later on and then down here i have just put a signature box which is just a png that just says sig box in it so i just made that in paint and i actually made that image the same dimensions as my powerapps input box um just to make things a bit simpler so that's all i did in there those three fields one two and the image so you might not realize this but if i copy this word document and rename it to dot zip you'll find that word documents are actually zip files if we go into here there's a couple of interesting folders let's go into the word folder and then in here there is a media folder so if we look at image one that's the logo that i had at the top of the page and image two is that signature box so that's the first thing and then if we look at document.xml i just pull it out to here and then edit that in notepad plus plus this is an xml representation of that document so if i search for name one two three four five here we can see it here and we've also probably got date one two three four five somewhere there now if this was if i had an uppercase d at the start of that this wouldn't be there there would be another field over here that just said d in it or something like that and then this would just say eight one two three four five so keep it all lowercase and we should be okay so let's move on to the next step so in my sharepoint document library i have got a folder called template in which i have uploaded the entire contents of that zip file if we go into here we can see media image one and image two and that is our signature box and that is the logo so the aim is that we want to replace that image too and we also want to use the get file content action to grab the content of this document.xml then i've got another folder called output which is just a copy of this template we're going to keep overwriting parts of that so then i've got a completed docs folder which is where that example just landed so let's have a look at the flow so the first thing the flow does is grabs the file content of document.xml from the template folder then we just do a simple replace action let's get this stuff in notepad plus plus so we can see it does a replacer action on the trigger that was the trigger that came through sorry it replaces the output get file content searches for name one two three four five and replaces it with the trigger action that came through so we've got name date and image the same thing is done on the date but the date is using the outputs of the replace name and the image is slightly different let's have a look at that i'll explain why it looks like that in a moment so if we go into the run history and have a look at the inputs we've got the name the date and the image if we show the raw outputs as we can see this is got a double quote embedded inside the text and then it's got this data image png base64 and a comma so all you're doing is doing a json on the trigger body to get rid of the escaped quotes and then i'm just replacing data image png base64 comma with nothing so that just puts it back to a pure base64 text so let's carry on going through the flow so now we've got our image and then we go to create file action so then i'm creating the document xml in this output stroke word directory calling it document xml and i'm using the outputs of the replace date so we're writing new xml into this output folder and replacing just document.xml as you can see that folder that um file was updated seven minutes ago while the others are much older so we then go to create image file and this uses a base64 to binary expression and just uses the outputs of that img base64 action and then we go into and this is really the secret source that makes this work we go into this create zip step i've done a whole separate video on this create zip which you can check out and this is basically going to take all of this folder and create a zip file from it i've been aware of this word zip file situation for a while and i've been trying to find a way to get power automate to manipulate that and the manipulation is easy but zipping it up proved to be more difficult but now this part is solved i'm not going to go into masses of detail here because there's a whole separate video on it um but the important steps are that we download the zip file that is created for us and then i'm just creating a word document in our completed docs folder and i'm just using the utcnow.docx you would probably use a file name in production that made a bit more sense and then we use that base64 to binary again to write the content that we've got back from sharepoint that gave us our zip file so well that is all there is to it really let's give it one more go because i just enjoy doing it um let's clear that out and we will type um this time and let's just do yay power my writing's not very good come back over to here and then we should see our completed docs hopefully in a few moments we will get a new document in here um with the output there we go it's pretty good isn't it so hopefully you can now give that a go yourself essentially this create zip part is the most complicated but if you go to my blog which i will leave a description for in the link below there is a whole video and blog post that shows you how to create these zip files quite quickly um and once you've done it you'll see that it's actually quite easy to do i thought i also ought to quickly show you how this powerapp submits to power automate on this submit button it runs the flow fill word document from powerapps and supplies it with the three parameters that's the text um input dot text the date picker selected date and then the pen image has is wrapped in a json expression pen input one dot image include binary data and that is all you need to supply so um try have a go do let me know how you get on because i'm quite interested to see how people will use this and this could be taken much further i'm going to have a play with that word xml to see if i can get some more advanced actions done like repeating content and repeating content with images so hopefully this opens the door to some more possibilities with word files the other thing is is that word files are limited to 10 meg and i've given given it a little play and you can go over the 10 meg limit using this method so best of luck let me know how it goes and i'll see you in the next video cheers bye bye
Info
Channel: Paulie M
Views: 1,320
Rating: 5 out of 5
Keywords: Power Automate, Sharepoint, Power Apps, Microsoft Word, Fill and Sign
Id: dHW-rAqx7qM
Channel Id: undefined
Length: 11min 58sec (718 seconds)
Published: Mon Jul 26 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.