 Hello everyone and welcome back to another video. So in our previous video We were looking at power automate and how to create a an automated flow so that every time an email was received You'd be able to store that or the attachments on that email into a share point document library What I'm going to do is just continue on from where we left off Just had a couple of questions about this were all valid points But also I wanted to cover off this element of adding some logic or a condition into this For your scenario so what we've got the moment and if you haven't seen the previous video You might want to go and watch that now else. I'm sure you can probably keep up We've got our flow here and we can see that we've got this current apply to each Attachment and basically all it's going to do at the moment is regardless of what the attachment is It's going to save it into our SharePoint document library What we've also got open here What I want to do is add in some condition or add a condition in here Which first tests what the name the attachment is so for us we're working with a staff upload So we we only really want to capture an attachment called staff upload from the email If there was other attachments attached to that we don't want to save those So this is why we're adding this condition in here to ensure that the others are filtered out And we only save the one we're after so what we're going to do again Let's say following on from where we left off. We're going to first Well, this might seem a bit of a reversal order But hopefully it'll make sense of why keeping this and we'll delete this bit out later on What I'm going to do first is add an action and That action is going to be a condition which for us has fortunately been up at the top of the list already But you could search in the search box to find it if you don't and when it pops up You'll see you've got this condition box here and also the if yes and if no so basically If we'll add a condition in here, and if that condition is true, obviously it will do the yes on the left side Else it will continue following this no option over here So what I want to do first is I'm going to go Into here and I'm going to say okay The first thing I'll do is I want to do a test on Attachments name so attachments name here is the same as the attachments name We're using here in the file name. So this is going to be the final name of each attachment So is equal to and I'm only interested in it's called staff upload dot CSV So if that's if that condition is met then what we'll do is we'll do this step So I'll let this open just for a cheat sheet for me to a quickly bad to enter back in So we'll go add an action here, and we know this is going to be called create file And we're looking for the share point option. So we just need to select our SharePoint site the folder path for us So we click this folder icon is going to be in the test archive and daily email to on that folder And then when it comes to the name of the file all I'm going to they should do is cheat sheet and copy everything from here So the first thing we want is a attachments name, which I can scroll down and find here Attachments name and obviously the content of the file is going to be again the original attachment content So we can see what that option available to us here as well And all I just need to do is add this little dynamic text we've got in here There are ways that you can do this so that You can do this in a condition and then you're able to reference it in each element what I'll cover in another video But for today, we're going to be sticking with our not to call it lazy, but yeah, maybe our messy solution So I'll take that go back into here to the start and we'll go into add some dynamic content It's gonna let me up. There we go expression Let's you're gonna put paste it in there and I want this to be at the beginning So the easiest way to do that probably is to read attachments name in here Just for reference what we're doing is we always want to retain the attachments name But we're just putting this date stamp at the beginning of it with an underscore so that as multiple days go on You have a date stamp as it's cool So you know which what each day refers to it just helps to keep everything tidy So now that we're regret run requested Replicated this element back down here. I can now delete this if I was to run this at the moment What would happen is it would create or save a file for each attachment You then do the logic and then maybe you would duplicate it or obviously if it wasn't met and not do it So I've got it down here. So let's just delete this one now Yeah, we definitely want to delete and now we can see a bit more about what's going to happen So when an email comes in what it would well just to be a bit more detailed as we know there's a bit of criteria here We're only looking at emails if the subject filter has daily attachment And then if that is the case what it's going to do to every attachment in that email regardless if it's only one Attachment or maybe 10 it will loop through each of those attachments And that's being done here by apply to each and it's then going to apply that this condition It will say right is the attachment name equal to staff upload if it is it will save it in our designated folder If it's not then at the moment It's not going to do anything because we haven't defined it to do anything here at all So happy of all that when I'll go down and click save And once it's happy yet, we just need to test it so we'll go back into our test option here into manual and go test So we're now in our inbox just to send ourselves a dummy Dummy email so that the workflow will will test it to make sure it's working. So just send an email to myself I've got make sure I've got the correct Subject line in here, which for us is daily attachment and Then I'm going to put some attachments So for this example, I've got three different attachments one is staff upload which we want to capture and then we've got a couple of Plug one so one called not staff upload and everyone called staff upload dash copy They've uploaded so let's hit send and we shall see what happens. So yeah, we can see the email has been received So let's go back into our flow for a second So this should now acknowledge that we'll see an email has been received into that inbox and then trigger The flow that we have associated for that Which should hopefully need to take a couple of seconds and there we go. We can see it's worked We've got our green ticks against each section to show that it has ran and obviously the useful information here to show Duration is taken. I guess the main reason I'd or more important side look at this If we were used to it being two seconds and suddenly it's gone up to 10 seconds That obviously indicates where you might want to maybe improve your workflow to obviously save a bit of time But nonetheless, it's all just useful information and then if we go into our share point We can see in our daily email folder We have got our staff upload attachment and we can see it's today's date So we've got the 25th of August here and our staff upload and this is the only file that's been uploaded So there's other two file names because they didn't meet the criteria. They have been excluded from Obviously being saved You might notice that or remember that one of those files was called staff upload dash copy So you can change your logic so that it and it says when it contains rather than when it's exact So I think I could probably show you that So yeah, if you go into our condition, you can see at the moment It's attachment has to equal this entirely. We could change that and say oh We only were interested if it contains so as long as it contains the word stuff upload somewhere that would work But obviously for us to be specific. We've put it is equal to stop upload What you could do here and what and probably is a good sort of way of working if you're dealing with this is you could create another Sort of catchable section here. So for us, let's say Let me just go quickly create a new folder over in here So you go new folder and we'll call this maybe other And then I'm also going to just delete this file out here. So we sort of start from a blank canvas as such Okay, so what we could do here. Let's add an action into no and We're going to do create trial and The site address is going to be the same The folder path is going to be slightly different. So let's go test archive Daily email and this time we're going to select other and Then I'm going to copy everything else into here again very much the same So again, I'm being very lazy here and just going to copy out this concatenation I've got good dynamic content and Then I'm going to use attachments name and then this last one is going to be attachments content So what we've done there is ever so slightly updated But it's paid maybe a good way of working Just think as a catch all for any of attachments So all this remains the same in the sense that if the attachment name is equal to staff upload CSV then great it's going to carry on and it's going to Save our target attachment to a given location However, if there's other attachments on that email, maybe Later down the line is decided that another attachment is going to be included as well as or maybe It could be any number of reasons. I'm really just trying to make some up the top of my head But if there is another attachment on this email this there isn't a staff upload What it's going to happen now is it will say well, no, this condition is not meant met But what I want to do is capture that attachment in an other folder, which we defined here so we'll just save that and We'll also test this new updated flow as well just to see how that's working. So we'll go into test manually go test and Like it's now instructing us go back to our email and get another dummy email made So once again, we'll send this to myself and we'll call it daily Sorry, mixing my words the subject obviously has to be daily attachment I think I mentioned in previous video that you don't have to do filter just based on subject You could run this on every email that is received from a certain inbox or person and then obviously apply A criteria to that daily attachment for the purposes example is just a lot easier for me to do So I'm going to just drag our free attachments back into here again to run our test They seem like they're uploaded. Let's send that email Perfect that's now come through Let's go back into edit your workflow. We can see our little Loading icon is here. So we'll just let that run its course And obviously execute the flow and see what it does with our attachments perfect. We can see it's now done Obviously this This is this section has taken a bit longer. You may remember it was previously two seconds But it's now four seconds that obviously we don't want to take longer than needed But it's a good indication that obviously it took a bit longer because it's now applying logic to those additional two files So one thing to bear in mind the more attachments on an email obviously the longer this flow is going to take to run But if we now go to our SharePoint site We can now see that as expected as we have previously it saved our staff upload file Dated today into our daily email. However, additionally now if you go into our other folder, you'll see we've got those other two files Also stored in there Just so we've got them for reference. Should we need to or should we want to catch them for whatever reason? I've obviously put the date stamp on there from as well game just good practice so we can identify when those files were received But obviously depending on what your criteria is you may or may not need to do that So I hope you enjoyed that video and you found it useful and maybe even answered one of your questions You had around a power automate Flow if it did, please don't forget to give this video a like and not only greatly appreciate by myself But it does help that all-important YouTube algorithm and also if this is your first time maybe finding one of the videos Or you've watched our videos before again Please can I ask you to subscribe to the channel and hit that bell notification button that way you'll be Notified of all of our future videos as they come out and of course as always if you have any questions about the content of this video Do just drop a comment below this video and I'll try to get back to you as soon as possible Thank you very much for watching and we'll see you in the next video