Power Automate for a selected item SharePoint trigger

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's show we're going to talk about power automate for sharepoint and we're going to do is work with selected item so first selected item lets us choose a specific item in a list and then have a flow trigger with that so that flow we're going to have some different inputs and we're going to take the output we're going to send it to an email we're going to send it to teams and we're going to talk about some functions that kind of shape the data a little bit too so should be fun should be fast but first here's our intro hi my name is shane young with powerapps 9-1-1 those guys and today we're going to talk about forest selected item inside of power automate or flow as you might call it whatever you call it we're going to mess with it because what we want to do is we want to talk about triggering off of a specific item and doing something with the data how we might have to go get some more data from that data or even shape the data there's a lot of little nuances here little things that i did to make it a little harder so if you've used this trigger action before you should get something out of the video because we're going to do some expressions we haven't covered before as well so i don't know i thought it was fun this came from someone left me a comment previously i said hey how do i do body body body as i uh that makes a good video so we're gonna mess with it anyway let's switch over to my desktop and take a look all right let's first start with the end in mind right let's go show you what it does so we're gonna hear my sharepoint site as part of my uh live sharepoint class i came up with some new dog based data all the different powerapps 911 dogs a little fun there um you know it was a good quest so here if we go let's go choose finn right so we'll grab finn right here and when we select an item in our sharepoint list we can now go up here to power automate and so i have a flow that shows up here called practice item and so if we choose that now you're going to say who do you want to email it to well just email it to me because that's the easiest one to show you there's me do you want to notify that person on teams of course i do don't notify them by email of course and we'll say say hi to the nice viewers there you go so this is taking input for selected item and then now the user says run a flow it is off and running and in just a moment we should see that over here in teams look here's a link to the item it was sent to you by shane young that's me dog name is finn christian and comments say hi to nice viewers and there is our cute little puppy oh so there's that and then what we're also going to see if i go click on my emails one sec so there you go i got the same thing email because i told it to send me both right so we configured all that but there's a few fun things that we're going to do here as we walk through the logic of the building flow and the hardest part though is getting this image in here so this is actually the thumbnail image this is not the full image file url that we had stored we said take that url and go find its real record and then from its real record grab its thumbnail and then put its thumbnail on here that was where i ended up spending all my time yesterday trying to figure out how to build this thing so let's talk about let's let's build one of these ourselves and i was torn if i should just show you the working flow or if we should build it ourselves i decided we're going to build it ourselves so first thing we'll do over here is go to create and it's technically an instant flow but it doesn't really matter uh because if you know me i'm just going to say skip here and so the first thing i'm going to do is go to sharepoint and so the there's a whole bunch of sharepoint triggers and usually we do think of things like when sharepoint item is modified or edited deleted but in the past we did for selected file that's where we took a excel file and sucked that in right we'll put a link up there if you want to see that one but we didn't process that excel file and save the data to sharepoint that was for selected file this time we want to do for selected item because we want to be attached to a list not to a document library so for a selected item we're then going to choose our sharepoint site and we'll keep playing with the doggy data i like that so we'll choose the sharepoint class and then the list we're going to do doggy data there we go so that's how you trigger now adding inputs is optional um but we know that we're going to want to do that so we're going to go ahead and add we'll add all three of the ones or what all four so the first one here we're going to do is we're just doing email and it's pretty much as easy as that and whatever you put here on the left side this is what will show up in the flow or for the user right so i got confused i thought it was what was over here so that's why i was messed up i had to fix it blah blah blah you don't care so anyway there's the email uh so then we're going to then have two yes nose so i'm gonna do a yes no i'll say teams all right we're just gonna make this easy i'm gonna write out a bunch of stuff i can't type very well and then yes no here as well this is going to be um email and then finally we'll add one more input for a text and what we'll do here is comments now one of the things i will tell you about these is now you do have additional options over here i never think about these and phil reminded me on twitter yesterday so if you go to comments notice here that if you want to change the comments to be a drop down or if you want to make the field optional you can change these behaviors we're not going to get into any of that right now or at least for this video but i thought this was worth pointing out to you guys you can see up here yes no make those optional email make it optional all right so we don't want it we want them to provide all this but we have the ability to control that and the drop down is a nice choice because i was like you can't add a drop down feel you crazy well you can't add it this way but you make it text and then you can so very cool thanks for that okay so that's for a selected item now strangely enough like when we start thinking about four selected i went oh that gets the whole item so let's just do a compose here and look for a second so if we go compose and we start to look at the dynamic content you're actually going to see that for a selected item doesn't give you everything right it gives you some of the properties of the file or the record in sharepoint you chose but not all of them and i need all of them for my work so what we're going to do is instead or not instead we can we're not going to just rely on four selected item the first thing that i typically have to do in these scenarios let's get rid of that is we're going to do another sharepoint and we're then going to get item and you got to be careful when you're choosing these because there's get items and get item we want the singular we want to get that one item that they selected because if we do a get item and so now we choose the same sharepoint sites all right i think flow should know if who knows where i'm going here but it doesn't doggie data so then now we use the for selected items id because the beauty of this going forward is we now have access to oh if i click the button from get item look there's all of our columns of data right we now have the whole record we have everything we'd look for so that's one of those little mental hurdles right i don't get what i want it's okay we can go get what we want because get item has everything so keep that in mind okay so that gives us the item that they just sent us and so from there let's do we'll do this simple first right adding that thumbnail was kind of hard like i spent like an hour an hour and a half i don't know too long figuring it out so let's do the easy stuff first so the first thing i want to do is i'm gonna do a condition and i'm gonna say hey if remember we did those yes no's so we're gonna scroll away down here and so we said we'll do email right so if email question mark and notice email this is the email address of the person who triggered it we don't want that we want email question mark is equal to oh and since it was a yes no the first time i did this i typed in yes oops i actually meant to type in true so email question mark is equal to true then what we want to do we want to send these people an email and so we'll do an outlook and then we're going to say i hate that send email so hard to find there it is send email v2 or whatever your latest v number is who do you want to send it to i want to send it to the um oh nope dynamic content and for selected item remember we had the email so this was that very top one where they chose email the first input this is the email of the person that did i think i just said that wrong like 30 seconds ago so email right here what is the subject how about something very simple hey look at the cute pop i thought a little smiley no i don't think it's my face working let's do that and so then in the body now so what we're going to do initially is we're going to do something easy right this was sent by and then we can use the for selected item and so here there should be a i don't want the user id i want the username let's try user let's type in search i think i had this problem before yeah so if you do search oh look now it's like oh there it is user name so they were hiding this from me this trigger for selected items seems to seems to make you want to work for it so anyway we're going to grab their username even though it didn't show up by default so this was sent by username um the pup's name is and so then this is from our get item and so here we're going to do name name and so this is going to be um first name and last name oh i forgot to put space in the middle there we go because if we go look at our sharepoint list i'm storing a first name and a last name column here so these are the columns that we're exposing over in flow so there you go so there's our cute pup there it they are and everything i did earlier just to and this will help us right so link to items so if you want to give them a link straight to the item we'll do a search for link here and then one more we're going to do a link to pup face and the reason for that is because in a minute we're going to have to talk about this face and it is hard so so there you go so that puts all the data in and for me this is enough to test right don't try to boil the ocean let's get our first test in and figure out if we're doing what we want but by putting these fields here i can also start to visualize the data i got to work with so we're going to call this um send a pup pic like that all right we'll say save now while this is saving i want to talk about one thing this forest selected item flow only shows up if the flow was created in your default environment right so if you're you have a bunch of different flow environments up here then you have to be in the default for it to show up over in sharepoint if you have no idea what i'm talking about then i bet you're already working in the default environment don't overthink it but just if you run into issues and it's not showing up it's because you're not in the default environment so it is saved it is good so if we go back over here to sharepoint just for good luck i'm going to refresh and let's just choose we'll choose that line hello adeline and so now we're going to say automate and when you hit this drop down hopefully there you go so there's practice item that's what i did yesterday and then i send a pup pic magically shows up so your user selects send a pup pic all right the first time they run it they have to consent to using their sharepoint and outlook connectors fair enough so then now it's like hey what email address do you want to send it to so we're just starting to type in me again there we go we could do we could also send it to chewie then it's like all right do you want to send it to teams it doesn't matter we're not using that one both say yes you want to send an email yes oh i forgot to include the comment you didn't show this oopsie so now we'll say run the flow so then that should go and trigger and if i look at my email i should have an email one sec so look at that we got we want an email to both me and chewie this was sent by me yeah it makes sense the pup's name is adeline boswell hi adeline here's the link to the sharepoint item and here's the link to adeline's cute little face hi adeline she's so cute don't tell anybody there you go chewie will get jealous so there you go that did i think everything we wanted on the first try right other than we gotta we gotta add some more pieces but but that's good right i feel nice that we got that good job team high five okay so then let's go over here to our flow again and let's let's make it harder harder yes let's make it more complex let's make it better but this is how i did it like when i was building this by myself down here yesterday jamming some sick beats sick beats i'm such a dork anyway when i was doing that i was definitely this is how i kind of baby step my way through it so one thing i know i want to add here is comments and so then for the comments right what would that come from well not from face comments was from our for selected item comments okay so that would have getting the comments in there now in order to do this for um teams what are we gonna do we're gonna go down here so we're gonna kind of minimize this make our lives easier we're just gonna add another new step another condition and so in this condition it's going to be should be our friend teams again teams right there is equal to true and so then in here we'll say add an action we're going to search for teams and so in teams we can you can do this a lot of ways right we've talked about these before i've covered this in my training classes but we could just post a message into a channel we can post a message in a chat or a channel and so the difference here is you know this one i can just post a message and i believe this one will just go in as me the flow runner but if we post a message in a chat or channel which is a newer one we can either choose to post as the flowbot or as the actual user that this flow is running its contacts that context as and so in this case i'm going to choose flowbot but you could go either way um the only time that you can't go either way is if you're doing like adaptive cards you want responses to then it has to be flowbot but this will just be me every will do flowbot anyway we're going to say where do you want to post in i need to post to a specific team's channel or a chat with flobot so this is going to be a post to a specific user and a recipient so this is going to be the um from our for selected item this is going to be the email field right this was who we wanted to send it to and then finally down here the message well remember you can always just come up here right we're almost in the same message either way i'm lazy i don't like to type too much so i'm gonna go back up here and i'm gonna grab my outlook one i'm just gonna highlight all this ctrl c go down here ctrl v it put all those pieces back together we could have reassembled it but i'm lazy so you go so that's enough change i think to test so we'll just say uh save now i'm not really sure what's going to happen here because we did both my email and chewie i did not test this ahead of time you guys want to be brave see what happens i do if it blows up well so be it we'll test this um okay so this test doesn't work right but this is not because of the shane chewie thing what this is saying if you want this translated this basically says that your test run had tokens for outlook and for sharepoint we just added teams there's no token for teams so teams can't can't be invoked from a test that's fair kind of neat though right so that's a very common error that really frustrates me sometimes until i calm down and realize it's my fault so let's go over here let's choose we'll choose clay hello clay and so now we'll say automate we will send a pup pick again should we be brave and try two people why not what is it not see here you can see it's looking to authenticate with teams for the first time all right if it breaks i won't hear about it yeah i'll probably hear about it anyway there he goes teams email comments hello people that's nice about people who cares run aflow all right so that is running and so now we're going to cross our fingers that i get notified here in just a second but because i'm a little nervous it's not going to run i'm going to click on flows i'm gonna go back here send a pup pic failed boom womp womp all right so it's saying hey there's no user that is both of those people okay so the thing that we've written will not work for two um two email addresses so we're not gonna solve this today but what you would have to do then i guess is go in because notice that they automatically get split by semicolon so we would have had to add logic to our flow to be like hey are there more than two people oh no there are and then run the action like loop through the action of some sort so so it's a solvable problem but not a solvable problem this morning because my kids gotta go to school in a few minutes okay so there you go we know that that doesn't work let's go back over here let's try um let's try murph another lemay dog let's send a pup pic this time let's only send it to me there we go we'll put in shane send it in team send in an email this better work there we go and finally we will run this flow all right so that is running boom i just got notified in teams now you notice over here in teams um this will better work so in teams these urls are not automatically getting formatted interesting but if we go to our email they do okay so what this is telling me is that outlook is figuring out how to auto format these teams it's not no big deal we're going to go back over here we do not yeah we'll just go hit edit we know that ran right worked so then what i would want to do is actually come in here and so after you've got this kind of close you've got all the right pieces if you hit this little button here this will change to the html the code view scary and so what i can do is i go up here like hey link to item and so then i'm just going to be like a href equals single quote sure it's right there close my single quote oh no see this is why you got to check go end single quote there and then we'll close that we'll say click and then we'll do a close the a so just like that that should add that as an actual hyperlink let's try it test automatic boom boom boom and boom okay there you go we'll go back to flow and look link to item is now an actual clickable high point so you just have to know a little bit of html we've talked about this before you guys have to learn a little html but there you go we've got it you might also notice here this confused me as well this was sent by ut so when you run this particular trigger and you test um if you reprocess the test it will always the the sent by will not be the actual person that sent it it'll be some weird letters and numbers so that's normal but if we went and clicked it over in the browser again in sharepoint we would get what we wanted so all right there you go so we are almost there we are also kind of getting along so let's do the final piece of this puzzle and that is get these people's thumbnails in here so i'm gonna have to do this and get it right so what we're gonna need to do here is there is no way right because right now if you think about it we don't you know over here these pictures these are actually this is a hyperlink column to a sharepoint document library that we're set the hyperlink column to a picture status that's how this column works that's why it shows the picture fine here but in reality the picture's not in this list it's in the document library and we're just referencing it pulling it in so on the flow side this makes things a little a lot a bit tricky for us so if we go over here to add an action and we go to sharepoint so there is actually a um get a file or get file properties by path and i'm never going to find it by by scrolling through so we're going to search for path so there is git file metadata using path okay so you have to use this one first because in here what we'll see and this is how i like walk myself through this we're going to eventually there we go click on sharepoint class and then the first thing i did was i was sorry all right let me go see like if i go grab mr face directly right so we click right here and we go in and we'll just go to clay and so we go to clay what i'm going to do is i'm going to say okay that looks like what i expect i'm going to click right here and we're going to do what's called peak code this lets us look at our code and so what i'm really after here is how did they handle this so they handled it it's a forward slash dogs which is the name of the document library and then clay the dog okay so that gets me my brain thinking all right i need to be able to get to that dynamically but before i go all the way with that i want to because i know there's an issue we're going to come we're going to go a little bit further so we can you know get through this so anyway this will get us the file metadata using path file metadata does not give us the thumbnail so what we need is we need to now say back to add another action and sharepoint and then get get file properties okay so this is what we're going to do now you're saying why do you go straight to get file properties because unfortunately get file properties only takes an id i didn't have the id until get file metadata using path which would take a url gives me an id so then down here for id there's item id and so now we can go in here oh i gotta i'm going backwards for some reason sharepoint class sharepoint library names and dogs so there you go so this is another one of those things i spent more minutes than i care to explain but i couldn't get where i wanted directly so i kept having to find these intermediate steps you've got to be brave sometimes you've got to just not give up you're like hey i know there's got to be a way to get there and then right because we've had to pull in two extra item two extra things so far right the extra get item to get the like the dog's first name and last name and we had to pull this in to get the id of the file that came from get item so that we could put the puzzle back together so that is very important to understand but now that we've done this now if we go down here we're just throwing the that we've been showing teams we'll go down here teams and so in teams guess what you get to write some html again oh before i do that what i'm going to do is we're going to say thumbnail and we're going to then say alright from file properties now where to search thumbnail so there's a small a medium or large which how big do you want to be let's go with medium that's what i've been using okay so that pulls it in but this is just going to give you the url to the thumbnail boo so what you're going to have to do now hit your code thing again and so i'm going to go right here i am going to just get rid of the word thumbnail actually i didn't want that and so we're going to do an image tag so img and then source equals equals single quote oh there's that extra space can get rid of that go to the end single quote and then finally close your image tag so that's what it's going to look like um when you get the image source it's going to be the url to not the full file to the actual thumbnail all right this seems close enough to test so we're going to say save now we didn't add any new token requirements so i don't actually have to go over and trigger it we should be able just to do our test succeeded right here so we'll just do a test this way and also one of the things to keep in mind with this is hopefully it's going to work that's first thing yay look at that it's murphy lee the pop murphy lee lemay not lee murphy murphy lee someone else murphy may the pup so we got the image in here now keep in mind that this thumbnail is a link to um sharepoint file service body body body so these links might not work if you're getting outside the ecosystem you know it's like if you're trying to send it to a customer this thumbnail is probably not going to work because they're not going to be able to get to the thumbnail i haven't played with it that far but internally everyone's already authenticated to sharepoint their life so they should be able to see it but just keep that in mind when you start trying to suck these thumbnails in because they are urls they're not the encoded version of the file you might have some challenges there but there you go so that works now the last thing we need to do is up here i want to go up here and show you guys so get file metadata using path so it's like hey dogs the clay so this this worked but we hard-coded it so now what we need to do is we're going to the last hard thing oh this video is getting long is i need to get this dynamically so we're going to say add an action and we're going to do a compose there's the compose and so then in this input here from get item we are looking for dog face because that is the member from our email that's the url to the dog's face which is what we're going to use we're going to have to break down and get to this format so there's dog face but we don't actually want that we want to do an expression here and so there is a string expression called replace that i chose to use yesterday oh that's cute it's not look at that see more see let's not do anything let's click out let's click back in let's try this again expression amazing i got stuff in the search box over here who wants to scream it flow for me oh that's weird i've never seen that behavior before okay so in here we're going to use replace become a replace the full url so what is the full url that is dog face reminds me of micro face from planet money and what do i want what is the old text i'm looking for so in our case it is oh i might have been able to grab that oh geez old p chain let's try skin replace content dog face uh flow is challenging sometimes let's go right there so string single quote aha i grabbed it though so this is the whole url to the sharepoint site right so we're going to look in that string and find the base the root url because this will be in all of them but we want to pull it off because we just want to start with the single splash and what do you want to replace it with nothing so just a blank like that should be a closing thing all right so let's grab this formula real quick ctrl a control c say okay so i don't have to do it again so if you go right here you can say add a note and if we do that now you guys can see the whole thing right replace outputs dog face wit find http blah blah blah blah blah and then replace it with two single quotes which is nothing so that will strip that off the front of the url so we should be left with dogs clay the dog now i know that this doesn't actually work so we're going to skip the error that would happen but what happens is it acts this down here it doesn't tell you but it wants an encoded version not just the straight string so what we're going to do right here is we're going to go back up here and in our expressions there is a encode uri component so this just takes and puts in like percent 20s for all the spaces and replaces all of the slashes with percent 53s or something like that so you just wrap that beautiful thing that we just wrote in that and then we'll say control a control c so you can see it update we'll close this one we'll add a note edit note ctrl a we'll put this one in now so you can see the whole thing so then that will actually put it in the format that we needed so then now down here we're just going to say add dynamic content and take that composed as output and then delete all this technically you wouldn't have to have the compose you could just put this exact formula down here i like to break it into separate especially when i'm teaching because it helps you guys see it better but i kind of think that might work so then yeah let's save it it is saved let's go over here let's trigger it with a new dog so that way we know if we see new dogs we get it oh how about adeline's uh little sister zoe she is a troublemaker right here allison has great stories about her so we're going to say automate we're going to say send a pup picture we'll do me again we'll do this we'll do this and then we'll say hi zoe we will run the flow and we will cross our fingers because well this video has gotten long i really need this to work on the first try please work all right i paused and i didn't get an email so i'm a little scared let's go back over here let's go here it failed all right what did i do wrong so down here i said get file using path dogs zoe png the file site file sites sharepoint class testing dogs zoey does not exist interesting interesting i feel like that did what i wanted all right hold that thought one sec oh you know what i used to get file metadata other way so i wonder if all right let's try this now i'm really not let's get rid of the encode oh i did not mean for that app let's go over here let's get rid of the encode and let's go over here so we're just going to pull off the stuff that we didn't want and now let's do another test do do so we're just getting rid of the encoding so this way it should just give it a straight string interesting so do we get there's zoey oh well how fun is that i learned something new watch trying to show you guys so here we said get metadata using paths so with metadata using path we did not need the encoded right let's go here let's go to the test run so you can see what it sent so on the compose it did dog zo jpeg and so here it did dogs zoe png not jpeg png but if we go look over here let me go show you guys so this is right this is the one that we did it works yay so if we go back over here to my other one the one i did in practice yesterday called practice item ironically enough so in this particular one instead i use get file metadata i didn't use the path i just used get file metadata it needed an identifier it had to be encoded so i had to use that encode uri function so there you go i made it harder on myself yesterday that seems like something i would do doesn't it but awesome possum all right so we've got this whole thing doing we wanted it right we're getting this last little step in our our flow that we actually want to do not the one that i want to show you so this is this one is we want to do the same thing in outlook but guess what you do not have to do you don't want to try very hard put your mouse in here control a control c scroll back up here to outlook control a delete ctrl a piece paste and so now you get the identical stuff if you really wanted to be clever you could have put all of this into a compose itself and then just reference the compose in the body of both these so you didn't have duplicates that would have been even smarter but that type of stuff gets weird when i'm trying to teach you guys kind of how this all goes through right so that's why i didn't overdo it i do not know where these weird href pieces came from let's get rid of all these that's weird href flo tried to fix it for me oh well you saw the right way when we were doing it earlier right we just went in here and we put in our link to item ourselves then we put a single quote here and we put a single quote here and then here oh and then we just did this there you go flow being helpful and confusing me as usual awesome possum all right hope you guys enjoyed this i know in the beginning it was easy and by the end it was like crazy that's kind of how i roll if any questions any comments leave them below also you know what because we had that whole problem with when i chose two email addresses it didn't work i'm gonna fix that and on thursday i will make a video on how to how i work through the logic there to loop through those two should be pretty easy i think because i think i'm just going to split it and then apply to each for the split so i don't know we'll find out on thursday uh yeah i said questions comments go below hit the subscribe button please thank you all right i got kids to take to school chewie's gonna go to the vet today and i'm teaching class all day it's a busy day so thanks and you have a great day before you go be sure to click on the subscribe button over here so that way you'll be notified when new videos come out if you need any help or you want to work together whether your problem is big or small check us out at powerapps911 we do it all i rhymed or if you're looking for more formal training offerings we have those linked up here somewhere so check them out thanks and have a great day
Info
Channel: Shane Young
Views: 35,993
Rating: undefined out of 5
Keywords: Shane Young, powerapps911, PowerApps, Power Apps, power automate, power automate tutorial, microsoft flow, microsoft flow tutorial, jon levesque, power automate for a, power automate for a selected row, power automate for a selected item trigger, power automate sharepoint, power automate sharepoint list, power automate sharepoint for a selected item., power automate triggers, power automate trigger inputs, button in sharepoint list to trigger power automate
Id: 8MSGwXazZRM
Channel Id: undefined
Length: 36min 4sec (2164 seconds)
Published: Mon May 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.