Everything you need to build Power Automate Approval workflow - 2/2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello in the previous video we learned how we can create an approval workflow the scenarios that we discussed were very simple basically we could create a request for approval and send it to one or more than peop more than one people and they could review and submit their vote whether approve or reject now then we also went through using branches to have multiple requests to multiple people as long as we know how many approval requests we are sending so we could create one branch for every single approval request and that approval request again could go to a bunch of people and each one of them could process it separately the key was that we didn't want any approver wait for the other approver to complete his or her job and then they could see it so the whole idea is that when we want to send this request we should be able to send it to all of them at the same time and they all approve it after all the votes are complete we wanted to collect the results and compile the final result of whatever we had this video is slightly different this is taking you through some complex scenario in this request employee is hired so there is simply an onboarding process during that onboarding process someone can create a request for this employee and there are multiple services available that can be given to this employee like benefits like health benefits company cell phone company car uh i don't know maybe desk phone or anything else and i have a package of these services in one sharepoint list now when the request is submitted the requester can pick one two three or multiple services for this employee and then each service has to go to a different manager to do the approve or reject finally after all the votes are completed it should create one compiled list of approved services for this employee sounds good so let's get into it to go through this scenario i created two lists inside sharepoint the main list that we are working with is going to be employee onboarding so when a new employee joins we create a list item here the job title first name last name and the service requests like company car health plan a wireless headset or anything else and these items are picked from this lookup list inside sharepoint inside the same site from a list called employee services that has a complete list of available services with the approver name and approver email obviously i could use the user field inside sharepoint but because i want to send all the approval requests to the same email i just decided to have a separate field with the different approval names so it will show you that each request goes to a separate approver although they all go to the same mailbox so obviously start and wait for an approval cannot handle this job because if you want to go through first request for the first item nobody else will receive the request we don't have a fixed number of requests so basically we cannot really branch it in this case we need to split this start and wait for an approval and work with two different actions one of them is going to be create an approval the other one is going to be wait for an approval so in one stage we create approval we send the email or we send approval request to the potential approver then when all the requests are sent we can wait for all the approvals and when they all received we can compile the final list now let's see what each one of them does create an approval creates an approval with an approval id because now not everything is in the same action we split this action so this weight should know which approval request it's waiting for that correlation happens using approval id so create an approval creates an approval id it sends the approval request to the approver either through email or to the power automate app regardless when the request is sent out it also returns the approval id to the flow we can capture it and when we want to wait for approval we can actually use this approval id so this poor guy knows what approval request it's waiting for and then it continues with the next step it sends the email it doesn't wait it jumps to the next step so right after we send the first request you can send the second request third request you can do five other things and finally after everything is settled down you can wait for the approvals one at a time now on the other side when we say wait for an approval it needs a valid approval id to work it waits until the response from approver is received so basically it cannot just move on it waits till the job is complete only after response comes back it continues to the next step again we just split this start and wait for an approval into two controls everything else is the same so before doing anything let me show you how it works there's a list for employee onboarding that i created so when we create a new item it accepts the title first name last name and requested services while the other list that i have is called employee services and employee services is a complete list of available services to any new hire and the approver name when i come back here if i create a new sharepoint list item i can add for example a cio for this company first name is going to be james last name is going to be smith and requested services okay let's give this guy company car how about a desk phone and what about a wireless headset three services you know what if you're not spending anything on it let me add four so let's keep the cio happy i click on save and the request is created as simple as that and every single one of them is actually referring to a list item inside the other list we want to be able to process these requests directly from inside sharepoint so when i click on automate here i should be able to pick up a workflow called for example process onboarding now let's do it so i go to flow.microsoft.com to my power automate portal i click on create and i click on instant cloud flow so i want to call it process onboarding [Music] and i look up for sharepoint for a selected item so basically i can select an item and i can fire a workflow related to that great i click on create for a selected item i pick up the sharepoint site power automate workshop and the list name is gonna be employee onboarding i just need to add another compose just to make sure it's working so i just pick it up here and i add the id of that list item here let me just save it just to make sure it's available on sharepoint let me just refresh this page and now from inside sharepoint under automate i should be able to see it it's called process onboarding so far so good so basically i can fire the flow from inside sharepoint great i go back to my power automate i just want to create a dummy approval request first before doing anything so if i click on new step i want to search for approval so i want to use create an approval instead of start and wait for approval that we used before so i click on create an approval as you can see approval type is exactly like before so i select for example first to respond title is going to be test assigned to i assign it to myself details i say test details and that's it now when this guy works it produces an approval id so i click on the new step and again i search for approval but this time i want to run wait for an approval and as you can see wait for an approval now requires a parameter which is going to be the approval id that i received from create approval so if i click on here under create an approval here under dynamic content if i search for approval id now this wait for an approval knows that any approval request that is correlated to this approval id is the one that it's waiting for and that's it just like before i can add a new step and i can put another compose here so i can track the outcome of this approval request of course i will get this response from wait foreign approval so inputs for this compose is going to be wait for an approval wait for an approval so let's go for outcome save we can test it right here at least just to warm up and understand how this request works so let me just save it again i go back to sharepoint and from inside sharepoint i want to run it for this cio so let me go to automate and i click on process onboarding it prompts me for the connectors we're good run flow and happily ever after now it should send me the approval request so let me go back to my mailbox okay open a new tab all right so i got this guy now if i click on it it shows me the request that i submitted with test details i may approve it and i click on submit i'm happy with this let's see how the workflow works so let me go back here god's sake i saved it twice okay so i have this guy here so let me just click on this and check the outcome first of all compose contains the id of the sharepoint list item doesn't matter at this moment but as you can see if i click on compose remember i approved it so the outcome of that approval request is approved fantastic so so far we know how we use it but everything that we did so far could be done by create and wait for an approval single control now let's go to our own scenario and see what it can actually do for us or go through the scenario that these two controls really add value you remember our scenario right so we have employee onboarding workflow should process item from employee onboarding approvers should come from employee services because i have approver names here and then we continue with the same approval request let's see the strategy that we want to go through and solve this problem first when the item comes i need to get all the approvers for each item so we find each requested item in the employee services list after that we send approval requests for all the approvers while we are doing this we have to create an array of all the approval requests with the approval id because remember when we send the request out in a loop we really don't know where the values are or what approval ids have been created so basically when we are running it in a loop we need to put everything in a power automate array if you have already taken my power automate expression course on udemy i will put the link in the description you exactly know what i'm talking about and how we can create an array otherwise just watch this video to the end if everything is clear for you fantastic if not the details about how to work with this arrays and how to work with this expressions here are completely covered end-to-end in my udemy course called master power automated expressions in two hours regardless let's get back to it when here we are processing all the requests everything should look like this in an array so i need to create an array that has approval id it has the service title and it has approver name remember all the requests are out after that after everything is out now we need to start reading the arrays so approval ids one by one and go for wait for approval and this is the time that we actually get our answers for each item and then we can compile the list of items into a variable and stick it into an email and send it out let's go ahead and do it so i'm inside power automate again i click on edit test compose i don't need it anymore i click on delete okay this one i don't need it either but i need to get a little bit of information from the selected item for a selected item does not return much it basically gives me the id and url of the item that has been selected so i need to actually first of all use sharepoint and i want to use get item get item remember get item not get items site address i pick up power automate workshop list name is going to be employee onboarding and id is coming from for a selected item id is selected let me just rename this to get onboarding request great after i get onboarding request i need to start with getting all the approvers for each item this one requires an apply to each from where all right so the field that we have here god's sake where am i okay the field that i am here requested services is actually an array let me show you let me come back here and let me just use a composer action compose and if i click on this compose i click on here let me search for it requested services the field name so if i put it here i don't need these two lines either let me just get rid of them delete and delete now let me save it and run this flow one more time from sharepoint so let me run it for this new cio automate process onboarding run flow done so i should be able to go there and capture it okay so this is the second run and if i click on it remember we wanted to capture the requested services you see what we get from here starts with the square bracket which basically means it's an array so basically we can capture every single item of this using and apply to each great so let me click on edit again i don't need this compose delete new step i use apply to each apply to each is selected and for this apply to each i look for requested services i want to rename it send all approval requests great now when i click on add action now i want to send the requests out and right after i send the request out i want to add an item to the array of all the approval requests so again i search for approval create an approval and i want to rename it to send approval request okay approval type is going to be first to respond we actually have one approver only title is going to be request for onboarding and i may include first name and last name from here first name space last name we are getting it from get onboarding request so this is the title assigned to who it is assigned to i need to get this item from the other table remember our diagram get all the approvers for each item from the other one okay i was supposed to do it before i send the request fantastic i did it a little bit by intention just to show you how to add something before that because before that it doesn't let you do that don't worry about it to add something before the send approval request click on add an action and use get item to get the item from the employee services so basically i want to use get item to get the item from here and from there i can get the approval name fantastic i come back here so i search for get item again get item not get items because we have the id so i rename it to get service which is good enough now to handle that now to have it before that you cannot drag and drop it before but you can get this one and drag and drop it after that so now we have the get service that actually gets a service from the sharepoint list that we want it is in my power automate workshop and the list name is going to be employee services this time remember employee services has the list of titles approver name and approver email right now the id is the request id so let's see here get onboarding request when we get it there is a requested services id which is the id on the requested services if you are using it here it assumes that this request service id is related to the current item of the apply to each so we get all the items that we need from here so when i go to the send approval request assign to can come from get service so get service has title and i need email approver email so it's assigned to the approver email and details let me put dear remember approver name comma enter employee i use first name space last name is hired please review and approve request for his or her what was the item that was requested i need to get it from get service so here i remove this last and under get service i'm looking for title great kind oh gosh kind records and workflow service great so basically now we are sending the request out if i go back to my powerpoint i send approval requests for all the approvers this loop at the moment does that thing but i need to create an array of all approval requests with approval ids great so this guy creates approval id as we know let's create a variable of type array that can have this information here to do that i go before the loop somewhere before i add an action and i search for initialize variable the variable name is going to be approval requests let me just rename the control properly initialize approval requests type is going to be array value i don't put anything here but when i come here after the approval request is sent i can add another action and i can append the row to the array that i have so i use append and i scroll down append to array variable and i need to pick up my array the value that i want to add is going to be a json object so the first parameter is going to be approval id double quote approval id i just remove the spaces and approval id is going to be approval id from the send approval request right so i can see the send approval request and i can add the approval id right between the double quotes comma the next parameter is going to be the service title so i create another property called service title just like before colon double quote and inside it i put title title from the get service what else and the last one is going to be the approver name again i can put approver name and this approver name is going to be approver name i get it from get service correct get service was getting the service from the second table approver name i got it i forgot the double quotes here don't forget to enclose it in double quote so approval id service title approver name let me get a copy of it and put it in notepad i paste it here what happens as the value doesn't really matter i just want the titles okay okay fine i just need these property names exactly the way they are when i want to capture them fantastic i go back here save the only thing is that i need to rename this and i can say append to approval requests let's save it and we're good so so far this guy reads every single item sends the requests out and adds them to an array we are done with this and we created our array so far now it's time to wait and get the approval requests to do that now we need to read the items from this array so let me come back here let me collapse this one i need another apply to each that this time this applied to each let me just rename it i call it weight for all approval requests what is going to be the item that i want to apply to each you got it this is the array because now i need to pass the approval ids one by one and get the responses back so i come back here variables approval requests that's array that i have so inside this i need to get every single item so basically the apply to each current item and get these properties approval id server title and approver name of course i also need to capture the outcome to do that i click on here first trick that i use i put a compose here this is one of the things that you have to be creative to use it and i call it current request basically it's a current item i come inside it i add the current item here don't rush and click on the first one there are two current items one is send all approval requests that goes back to the previous loop you don't want to use that the second one is wait for all approval requests this is the current item of this loop so let me just select this one and you may ask ali why do you put it in compost we can use it directly no you cannot and i'm telling you why well you can't technically but it's a lot more hassle this one makes your life whole lot easier let me get there in a second so current request is the current item that i am processing and actually on every iteration this compose will have an instance of this object when i have that now i can start processing it in a wait for approval so let me just search for approval again this time i need wait for approval and i can say rename it and call it wait for approval response the approval id that i want is going to be the current item of this array the current item i need to get it from here yes you can see the current item here but we need to use expression because we don't need the whole item inside it i need the approval id of the current item correct see how i do it i go back to the approval id i click on the expression tab i need to pick up the current item under the expression tab to do that i come back here i press space i go back to dynamic content and i search for the current item or the current request output see i can select the current request output but if i scroll down for some weird reason power automate does not show me the current item that's why i put it in a compose and then i call it from compose after i'm here i just say dot control v and i put my approval id from this notepad here good right after i'm done don't forget to remove this extra space that i added in the beginning just to trick the power automate designer and you're good to go so now this loop at this stage is waiting for one single approval request it doesn't mean that it is the first one that is being processed but until everything is processed we don't have any rush to finish this approval request because everybody has received their requests and we are waiting for their approval so after this wait for approval response works and comes back we need to get the response and add it to an email to add it to an email i also want to add another variable right in the beginning again i look for initialize variable i call it initialize email text email text and the type is going to be a string i leave it just blank now if i go for wait for all approval requests after wait for approval came back i can click on add an action and i can add append and this time instead of appending to an array i'm appending to a string and this string is going to be my email text the value that i want to add is going to be the title of the item that has been approved or you know what let me put all the approved and non-approved in one email and compile everybody's final answer that's going to be more comprehensive so i would say request for i have the title right so i can click on expression again again the same technique space i click back on dynamic content i select the current item here current request output dot i need the service title right so i add it here again don't forget to remove that space in the beginning so request for the title whatever the title was is approve or reject let me put it in double quote you can put it in anything again i need to get the output from wait for approval response so wait for approval response i need to get the outcome by who was the approver remember we have it in our array it's called approver name right so i want to come back here request for whatever is approve or reject by and i can go to the expression and use the same trick here space i go back to the dynamic content and again i'm looking for current request output and again dot approver name i go to the beginning and remove the space click on ok and because i want to send it as an html i use br forward slash as the new line character good let me just save it so now every response that comes it generates one line in the email that i want to send out i know this video is getting too long don't worry we are almost in the end so after all the items are processed here we are done with navigating through all the requests in the array and pass them to wait for approval and for every single one of them we added request outcome to string variable as email text fantastic all we need to do is just send the email out new step so i come back here and i say send email send an email v2 and i send it to myself right subject on boarding services for and i search for first name and space last name good and for the email body i just add the email text well i usually should put hello how are you and all those greetings and stuff in the email but at the moment i don't have time and i don't have patience for it and i just rename it and i say send final list to hr okay click on save moment of truth let's go and test it so i go back to my sharepoint site and i want to process it for sharepoint developer let me just click on automate and i say process onboarding remember there are three items work from home company cell phone and s4 let me just click on continue run flow and now i should get three emails that has three approval requests for work from home company cell phone and desk phone for someone called first name last name ali raza ali already so let me go back to my mailbox and see what i got first one there's a request for catty this request is for work from home let's see if he sent it to the right person here work from home is gone to cathy of course it's coming to my mailbox i'm good with that gosh here i just approve it this guy is a nice guy let him work from him second one the request goes to sarah for company cell phone let's see if you're sending it to the right person was it this one yeah company cell phone it goes to sarah perfect you're good so i can go back to the mailbox let's approve this one too and finally there is a request for desk phone for god's sake this guy is a mobile guy no let's just reject it but it goes to kazamfer and let me just double check and it that we if we got it for the right person yes chasm fair receives the request for desk phone fantastic and this guy says submit and reject it fine moment of truth onboarding services for all your resilient id request for work from home is approved by catty requests for company cell phone is approved by sarah request for desk phone is rejected by gas and fair and if you like this video you know what to do all right that was all about it i hope you enjoyed this video and we almost covered everything that we needed to learn about working with power automates i cannot really imagine any other more complicated scenario for the power automate approval than what we discussed and what we went through today uh just one quick note i will be disappearing probably for a month or so to finish the course that i have in hand for udemy uh meanwhile if you need anything if you want to reach me for something like a quick question or something like that either put your comments right there or uh you have my contact on linkedin i my contact on linkedin is also in the video description you can always reach me through linkedin and if there is anything that i can help by all means i am quite busy so don't expect quaitanz quick answer on linkedin but i do my best to catch up as much as i can next video i'm going to tell you the new course launch on udemy thank you for watching stay tuned and i'll see you soon in the next video you
Info
Channel: Alireza Aliabadi
Views: 4,023
Rating: undefined out of 5
Keywords: Power Automate Approval workflow, pwoer automate approval workflow, power automate aproval workflow, pwoer automate aproval workflow, power automate approval workflow sharepoint, power automate approval workflow sharepoint list, pwoer automate approval workflow sharepoint, pwoer automate approval workflow sharepoint list, Create an approval, Wait for an approval, Advanced approval, Power automate complex approval, Alireza Aliabadi, Alireza A. Aliabadi
Id: I63FRNRO4p4
Channel Id: undefined
Length: 40min 26sec (2426 seconds)
Published: Tue Feb 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.