Power Automate Tutorial - Expressions 301

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] what's up guys welcome back john levesque here and i am joined again by the man reza durrani how you doing sir hello john i'm doing good how are you doing i'm doing pretty well i'm trying to stay inside and hide away from all this wildfire smoke but other than that i'm doing pretty good and doing pretty good how about you same here trying to stay inside uh trying to avoid going out as much as possible yeah it's crazy right now it's crazy yeah well hey for those of you guys that don't know raza he is a business applications mvp he is a super user in our communities he is all over the place on twitter making videos on youtube and writing blogs he is a content king so we've done expressions 101 we've done expressions 201 and reza is here to raise the bar again and bring us to expressions 301 so if you want to see a deep intro on him go ahead and check out 101 go ahead and check out 201 but for this one we have a lot to cover so i'm going to hand it right off to you razer to take it away my friend absolutely all right so let's begin with expressions 301 now the goal for expressions 301 is to talk through some real world business use cases and how we can parse information transform information and use the power of expressions to truly truly take our flows to the next level that's the goal of 301 of course if you have never worked with expressions before as john mentioned please go ahead and check out 101 and 201 that will give you the basics you need to get into 301 yeah if you watch this without watching those you're going to be in a world of confusion definitely go back so 301 is going to focus on some real world use cases and before we get into that the first thing i want to cover as part of today's session is going to be json it's very very important to understand json in flow and how we can parse json in order for us to leverage this concept in all our scenarios now the flow that i'm currently demoing right now is a very basic flow that triggers when a user clicks on a button manually and in this flow i have a json object that i have created and this is what the json object looks like now what is json json is javascript object notation and this is typically the output that you receive when you make calls to any data source or any service in office 365 or even beyond now for this example i have a list of students that i am maintaining manually in my flow for now the format here is is is the json format and this is my list of students right here now in this i have a node called data and this data node has a square brackets notation in front of it that means anytime you notice that there is a square bracket notation then we are dealing with arrays or we are dealing with collections that's number one that's the first key thing that you need to remember square brackets means arrays or collections so in this node of data i have a collection of students here's my first data node here's my second set and here's my third set so i have three students here right here sabrina karen and myself so we have three students right here and i have their information and i have their first name last name address and so and so forth that's the structure of the json right now that we are dealing with as part of this exam now right here i have a compose action inflow that i have created and in this i have pasted that same json structure that i showed you earlier so i have a json output that this compose action will provide to me now i will show you how we can leverage expressions to pass through the different items in that json structure so the first use cases get me the first student's address so the first student right here is sabrina and the address associated with sabrina is 69756 wendy junction so how do we grab this information from this json structure so the way you do that through expressions is this my expression is from the students json object which is right here if you notice i'm going to try and zoom in as well so we can see this clearly so right here i have my students output and from this i have something called as question mark that i've put in i'll explain to you what question mark is then i have this notation called data right now what is data if i head back to my json object right this is what my json object is and in this i have a node called data so that's the node that i'm grabbing right here it's point number one that's why the word data the next thing is within data if you notice data was an array right remember i showed you data begins with those square brackets that means it's an array it's a collection if you want to fetch records from a collection you can just put the node entry that you need so if i need the first item arrays begin from position zero i have put position zero if i need the object at position one then one and so and so forth right so right now all i've done so far for my parsing is i've said go and grab the data node and in this grab me the first object now once i have the context of the first object i want the address so what do i do very simple once again just put the address notation right here so that's how i am parsing through my json object i'm getting my json object getting the data node getting the first item of the array and then getting the attribute address i love how simple you make that i feel like the first time i heard about json i was like wait who's this jason guy everyone's talking about now the way that you broke that down i'm like wow this like i could do this it's funny i don't mess with the json too often even i myself i try and stay in the builder but uh that that just opened my mind even so yeah thank you so the goal here is try of course the goal here is to understand json at the same time not to make it too complex right yeah yes once you see i see a lot of folks who look at json especially in the community forums and they get confused around you know a lot of questions are around json how do i get this how do i grab that data it's actually very simple once you understand the structure of your json and in real world cases once we get to the business cases i'll show you how you can understand the structure based on the response that you receive based on the actions that you query and flow very cool so right here i've just gone ahead and grabbed my information and that's my simple simple expression that i've put right here now first things first what is this question mark right here right can i can i just not add this question mark and will my expression be correct yes it will still be correct your expression will still work now when you put the question mark what it basically does is it adds a null check to it okay so it basically first checks to see if there is a node of type data if that node is existing only then the expression will move to the next part of my expression that i've defined right here if i don't put the question mark that means you are 100 confident that the json object that you're providing to this expression has this data points available for it so if my json let's say has no data in it this this expression right now will fail it will throw me an error and your flow will throw an error if you want to avoid that best practice always put question mark in between each attribute call that you're making to your json nice so that's the reason why the question mark isn't that it's pretty handy great tip okay so that's how you get the first student of course i'll execute the flow and i'll show you how to grab the first student next thing is let's say i want to filter all my students and i want to grab only those students where the email address contains yahoo.com okay i have three students one which has yahoo one has gmail one has gmail so two gmails and one yahoo now how do i filter this now in flow there's an action called filter and if you've never used this before i'll show you how you can search for it just search for the word filter and it's a data operation it's called filter array now the key thing to understand about filter array is it requires an array requires a collection you can't just give this a string or an integer you cannot do that it has to be an array so in my scenario right here if you notice how do i give an array right here now in my scenario i have composed students right compose students if you look at the json again is not an array what's an array the data node in compose students is an array this is an array why because it has the square brackets right here this is what i'm really interested in so how do i get that information and let me go to peak code to show you how i put that code in i am basically using the same expression which says compose students once again there's a question mark in there because i want to make sure that that node exists and data so i am giving it an array which is my data node right here and in this i want to filter the array based on what based on the email attribute right now how do i grab the email attribute it's very very simple in my object i have email right here so i need to go ahead and grab that and the way you grab it is go to expression and there's a function called item item basically gives you the current item in your loop or in your filter scenario okay it gives you the context of the current running item in that filter scenario so what i'm saying is for that item once again i'm putting that same question mark go grab me the email node that's all i'm doing right here that's my expression and in this i'm checking to see if this contains yahoo.com so basically all i'm saying right here go and filter my json based on the array provided in that data object and then check to see if the email contains yahoo.com and the output of this expression or the output of this action is also another array and then i'm just trying to see how many students have the email yahoo.com very simple i'm going to use another expression called length we've used this before in expressions 101 and 201. there's a function called length and all it expects is an array and i'm giving it the output of my previous action as simple as that let's go ahead and test this of course this action that i just added needs to be removed because it's empty so let's go ahead and run this flow and let's now look at this flow in action so my flow got triggered the first step is my json and this is how my json looks like i put this in visual studio code so we already know the structure now i need the first student address which is right here it should output six nine seven five six wendy junction and that's exactly what it outputs right here so it went through and passed through the json then my filter action go and give me all the students where the output is yahoo.com the output right here and this is brand new and flow as well now you have this show raw outputs if you just click on this it will give you the full output so you can just copy this and go ahead and paste it in visual studio code so i can see my json structure clearly so if you notice the only student with yahoo.com was sabrina has gone ahead and grabbed that student object and in this i then ran the length function to check how many students have yahoo.com because my data node which is my object right here the body only has one item in the array the length will return one and that's the output that we see right here beautiful very simple very straightforward very basic example of parsing through json and these are very common scenarios that you're going to run into you will filter your objects you will want to count how many items are there in my object or based on a filter criteria you would like to count how many items are there in your arrays totally this this makes a lot of sense i have teachers asking me right now i'm trying to help them and they're like how can i send weekly reports for my grade book right this is a way that you could do that okay now that we've seen this now let's take some real world use cases so the first case is right here i have a application called help center when users come in and put in requests they put in ticket information related to a help desk application the data currently is being is being stored in sharepoint as a data source the second thing is when a user comes in and they try to create a ticket they have to select a category associated with the ticket now these categories are also being driven from another data source which is again a sharepoint list and for each category i have defined a set of approvers so the use case here is users come in and create a ticket in my system pick a category i am dynamically defining my approvers and i have a flow that will basically begin an approval process the moment a ticket request comes in and then once the approval process is complete it will track the entire approval process not just that it will lock the approval history very very important why approval history inflow is only valid for 28 days if you're not aware of this so you will lose your approval histories so make sure you lock them that's what this flow is going to show you how to do that not just that we will also write expressions to calculate how long did approver one take how long did approve a two take what was their response when did they take their response all that metadata information that's available as part of flow i'm gonna grab all of that and i'm gonna store it in my system of record amazing this is okay cool this is something that gets asked for a lot dynamic approvers uh so i'm actually excited to see how you handle this let's check this out so let's go through this process now the key here is to understand expressions remember the use case is simple but the goal here is to show you where i'm using expressions because without the expressions it would not be possible for me to perform this kind of a scenario so here we go i'm going to create a very simple ticket in my ticketing system right now so let's say i'm having an issue with phone connectivity so i'm going to say i'm having an issue with my phone connectivity this is a medium priority ticket i pick a due date for my ticket my phone is not working and i now need to pick a category for my ticket now this is what the user picks so in this case i'm going to go ahead and pick facilities okay i'm basically creating a ticket and notifying my facilities department that i'm having an issue with my phone okay please note this is sharepoint if you don't like the look and feel here we can even modify this using powerapps and we can make the shiny one further yep or a form or whatever front end you want whatever front end you want and honestly whatever back end you want as well and this example is just sharepoint you can have any backend you desire yep okay so let's go ahead and click on save now the moment i do this this is my ticket that's got logged in the system all my data points are right here and these little uh ui uh elements that you see here this is actually sharepoint list formatting so there's nothing special about this very easy to set these up and the first thing is observe that the status of the ticket is new because this was a newly created ticket now the moment the ticket is created i have a flow that kicks off so i'm just waiting for the flow to run let me first show you the process then i'll break down and show you how the flow works so just waiting for the flow to trigger all right so as you can see my status of my ticket that is phone connectivity has changed to pending and not just that there's a section called commands and it says that the approval was started by the name of the user who started this process which is me at this date and this time so it's actually grabbing the date and time in my time zone and applying that in sharepoint in a readable format through expressions i'll show you how later so that's step number one also it will dynamically assign the approvers now i picked facilities as my category so the approvers are sarah and james i have two approvers now i will log in as one of my approvers and in this case i am logging in with my approver which is james in this case i'm showing you approvals through teams and i'll show you how i did this as well in my flow by the way so i have that approval card going out directly to that approver in teams dynamically through my flow and in this case let's say my first approver comes in and says yes approve this is a valid issue working working on it right and they click on submit so the first approver comes in and takes the approval decision at the same time there's a second approver as well and this time i'll show you how to do approvals through the email oh nice email option so this is my second approver which is sarah and how did sarah and james come about dynamically through my flow by reading the category and let's say sarah also comes in and says uh yes this looks fine or maybe sarah says no you know uh i'm gonna reject this uh not an issue and sarah submits sarah's tough man [Laughter] so both sarah and james have taken their approval decisions and now if i have head back to my sharepoint list notice what happened right here because sarah rejected it it changed the status to reject it immediately not just that what i want you guys to observe right here is the approval commands now now let me try and open this and grab the approval commands right here maybe i can just add it so we see the approval comments in action all right right here are the approval comments now notice the approval process was started by reza at this date and this time that got logged then what happened then there were two more approvals that took place both of them need to be logged so here it tells me that james approved it at this date and this time it took james one minute to approve so remember it took me one minute to take that approval decision so i can even track and see how long did each approver take to take their decision something that many people asked for and the way i did that is honestly through expressions and through understanding the json that i get from the output of the approval action and that's why it was very important for us to learn about the json first so i'll show you now what we do here this hold on real quick real quick just i want everyone to appreciate the formatting of your comments like look at how much character those emojis add right like they they give this life they give this something that that somebody can look at and appreciate rather than just raw text raw data um that's phenomenal even above and beyond the the coolness of how this works and and what's behind the scenes the formatting of how you create things like this matters too and so i just i really appreciate those little touches thank you john it's it's important to add that extra touch it is it is it it makes people want to interact with the things you're creating exactly and it's a visual cue right it's a visual cue i can clearly see this is rejected honest sharepoint is giving me the visual cue but even the commands i can immediately focus on who rejected it thanks to the emoji right here yeah when did they reject it how long did they take right i can grab all that information through my process cool let's see let's see how it's made now let's see how this flow's made so here's my flow yes the flow is long but i will walk through the different steps quickly okay so the first step is of course the trigger of my flow which is when an item is created in my list which has helped us simple straightforward step number two i am creating certain variables that i need because i'm going to try and hold this information in my flow so i can leverage this later on in my actions my first variable is a variable of approvers of type string remember variables are strongly typed second variable approvers which is an array so i have a string variable and an array variable and then i have a comments variable of type array this is where i'm storing all that commands history and i'll show you how i'm doing that later on in this flow and those three actions right there are and uh initialized variables yes these are the initialized variable action once i grab this the next step is i need to go and get my approvers first remember my approvers are dynamically getting defined from a different list how do i grab this it's so cool i am using the get items action right here just squaring the departments list and here i'm using a very simple filter query that says go get me all those departments where the title is equal to the category that the user has selected in the form okay i will show this in run mode as well so we can evaluate the json but right now i'm just showing you the breakdown of the flow yep once i get the departments now the key thing is if you notice the departments even the approvers is technically an array you know why because this is a multi-select approval column and this is the people picker column and sharepoint so how do i grab the email addresses because when you create an approval in flow you need to get the email addresses and they have to be semi-colon separated that's the base premise of adding approvals in your approval action back to my flow so the next step was how do i get the email ids i am running and apply to each loop for every item that i get as part of this query remember the output of get items is always an array so i will have to loop through that then i am looping through each approver why because the approval column is multi-select so even that is an array as i'm looping through it i am going through and grabbing what the email of that approver why because i need that and i'm putting that in an array one by one by one by using another action called append to array and i'm just picking the array variable and just putting in the approvals one by one once i do that i have another action and flow called the join where you can give an array and you can join them by any text that you want i could have even written this as an expression there's an expression for join as well but thanks to flow they've given that as an action so i don't need to write an expression why reinvent the wheel yeah so here's my array and i'm just asking it to join by semicolon this will give me the semicolon list of email ids of my approvers dynamically and the next step is i'm just setting my string variable now remember data types to the output of this join action so i get my string of my approvers and this is how i dynamically grab my approvals wow once i grab this i am updating my existing item in sharepoint i'm setting the status to pending and this is where i put in my first comments in my approval log a little bit of emoji work right here literally just copy pasted it from the web nice approval started by the person who created it and hears an expression and this expression was something that i showed in the previous uh modules as well so go go and check that out convert from utc remember flow only understands dates and times in utc format so go get the created date of what of my item and convert it into pacific time because i'm working in the pacific time zone and format it to look like this month day year or minute time and that's why the formatting in the output right here shows me the month the day the year and the time that's because i have formatted it you can apply any formatting of your choice right here so cool once i'm done with this i'm using the create an approval action and this is where i'm applying that variable to dynamically define my approvals no hardcoding right here once i create my approval action i have written this additional step here to post an adaptive card to teams now not many people know but the approval action actually spits out a property called adaptive card you don't have to reinvent the wheel just use this action and post it as an adaptive card so if you noticed i took one of the approval decisions and teams that's happening through here nice i have a whole video on that if you want to see approvals through adaptive cards and teams i'll i'll put the link next step of course i'm waiting for the approval this is where i wait for both my approvers to take their decision now once they take their decision my next step is i am going through each response now what is responses responses is the output of the approval action and we are going to look at that json right now in there responses is an array so for each of those responses what i'm doing next is i am going and performing it looks complex but it's very simple i'll show you how i am appending text to the array of commands right so now i need to get the response of my approver and append it so the first step is i have a expression right here and this expression is an if expression so i'm checking to see something i'm checking to see if the response of the approver was approved or rejected right so what did the approver say if the approver said approved go ahead and put a proof with my emoji if they said rejected go put rejected notice i'm not writing a condition and i'm writing those additional branching logic i don't have to do that i can do the branching logic right here within one action by writing expressions and here's a very simple expression which uses the if function once i get that once again i needed the date and time same expression again convert from utc get the completion date converted to pacific convert it to your time zone next how do i get the time how do i get how long the approver took to give me the response now unfortunately or fortunately inflow there is no direct way of getting that there is a function called ticks t-i-c-k-s so if i go to list of functions and if i search for ticks i c k s and if i click on this takes basically gives me the hundredth nanosecond interval from a previous date so it basically gives you a nanosecond intervals now i don't want to confuse you guys just think about it that text gives you a number based on a peculiar date just think about it like that it just gives you a number as a response based on a peculiar date this was a crazy one for me to understand also when i first heard about this i'm like why there's got to be a better way but there is not a better way right there's not yeah you know i have a blog post on this uh that i posted in the community forum so i will grab that link as well and give it a joke we'll have it in the description of this video so i won't spend much time on this but basically all i'm doing right here is writing expressions to check the interval between how long the approver took to respond and when was the approval action assigned to that approved and this is what does that calculation of course there's a lot of match here 100 and divide by this multiplied by this is basically some time calculations going on here to give me the exact time in minutes that the approver took and that is what i'm plugging in right here and finally of course once i'm done with my approval array i'm again joining it with a space because i wanted to space out my approval actions or the approval commands and then at the end i'm checking to see the response whether it was rejected or approved and based on that i'm just going ahead and setting my status man i feel like wow that's like i just feel like i sat through a lesson on like how to create a symphony like that was it was like a master class wow that is a beautiful flow thank you and when we run this flow all i wanted to show you guys was this so the create an approval action we'll just look at one thing to create an approval action we are going to focus on the body attribute that it spits out so i'm going to copy this of course there's not a lot of space here so i'm just going to copy this i'm going to open visual studio code and paste it here now what is this this is a json once again right now all the skills that we applied earlier in understanding what how we can traverse through json now we can understand this now if i need to know how many approvers were a part of the process very easy just get the stored this will tell me how many approvers were part of the process perform a length operation on this there were two there are two objects if i want to know what was satisf all that information is available right here okay the adaptive card is also right here right the properties are available for you and once i hit wait for an approval this also has the response of my approvals now let's check the outcome of wait for an approval this is again an array of responses right so these were the responses now i can traverse through this get the individual responses so sarah said rejected and here is status comments this is what i'm actually traversing through in my function sarah so rude yeah she's rude so all that information is available right here for you to capture and grab and when i calculated the time aspect all i'm grabbing is the request date which is when did this request go out to sarah and the response date when did sarah respond and then i wrote that function for ticks which calculates the difference in minutes to check how long that sarah took to respond same thing goes for james and so and so forth so understanding json is extremely extremely important in traversing through outputs of not just approvals but any scenario of your choice and and understanding it can help you build epic approvals like you just saw all right thank you let's get to use case number two now i have tied use case number two very closely with use case number one okay now whenever a ticket gets created there is a unique id associated with my ticket so as you can see for this ticket that just got created the id of the ticket is ticket number 19. now many a times uh there are requirements when i want to send an email out with a particular subject a particular body available maybe attachments in it and i would like the email once it comes in i would like to grab all that information that the email has and then apply some logic to it and maybe grab my attachments from my email and push it right here into my system if the id of my help desk matches thanks very common use case again yeah so first let's look at the flow in action this is my flow and what this flow is doing is whenever a new email arrives and that email needs to have a subject that looks like this helpdesk ticket right if the email subject contains this subject and it has attachments then in that case i'm going and grabbing the ticket number based on some logic and i'll show you once we run this flow i'll show you what that logic is once i do that i'm basically going and grabbing my help desk item based on the ticket number that is provided in the email and then i go and grab each and every attachment that i get as part of the email and i'm appending it to that item so let's look at this one in action i'm going to log in as a different user and i'm going to send an email to that email address in my case the email address is reza's email address here is my subject now as part of my subject i need to also define what my ticket number is so in this case it's ticket number 19 so let's get back to that user's email and let's put ticket number 90 and maybe i'm going to provide some sample text sample text as part of the body and i will go ahead and attach a file i will grab a file and of course i can add additional attachments i'm going to hit set so i've basically sent an email that has a peculiar format associated with it and i'm also attaching a file and sending that file out now once that information comes into the system of record this flow will trigger so i'm waiting for the flow to trigger and as you can see nine seconds ago this flow has successfully run and what this flow is going to do is if i head back to sharepoint you see ticket number 19 there's a small change that took place you see attachments it shows you that there's an attachment now nice if i select this you see there's a file attached and the file has a naming standard that it is following plus if i click on it i can actually look at that file by the way shameless promotion of my upcoming [Laughter] so as you can see that an email came in that had a peculiar format it had attachments and somehow there was a flow that was waiting or listening for an email to come in with a peculiar format it picked all that information and pushed it to my system of record now let's see how we did this so this flow let's look at how this flow executed so an email came in and the first thing that i did is i grabbed the ticket number now ticket number is a variable i created here of type integer and the next step is i am setting that variable and i grabbed that number out i'll show you how through the expression later but i grabbed the exact number from my subject so it was helped us ticket 19. i grabbed the number 90 why because that's what i'm interested in the ticket number then i queried my sharepoint list and i passed that ticket number that i grabbed from my email so ticket number 19. go get me that sharepoint item once i got the context of the sharepoint item right here all i had to do was loop through all my attachments as part of the email and one by one start uploading them to that sharepoint id wow now let's look at where we used expressions so first right here is my first expression i have a variable that i created of type integer now when a new email arrived in my mailbox the subject that i received as part of the output property the subject properties of type text but i need the ticket number in the form of integer this is another very common request that i see on the forums and in fact i saw a lot of comments in our 101 and 201 series as well how do i translate something from one format to a different format right now if i go back to the flow run once again json is very important to understand guys my trigger action has an output which is of type json so i'm going to grab this and of course the json is going to look a little daunting and the way you format this is ctrl a alt shift and f and it's formatted so it's no longer confusing now let's see how can i grab the subject so here's my subject guys help desk ticket 19. remember this is what i'm interested in the subject how do i grab this through expressions let's check this out back to my flow so right here if you notice first thing is i am performing a loop through something known as a value node now if i try and zoom in right here and if i hover on this look at the expression behind this it says trigger body question mark value now why value remember apply to each needs an array so if i head back right here value right here is the array right from the body this is the array it needed so it got the array which was perfect now from this how do i grab the subject now first thing i am grabbing the subject right here by using that same concept i showed you earlier question mark subject and what is subject subject is the node that is available as part of this object right here so i have grabbed the subject perfect so i got helpdesk ticket 19. now as part of this i am interested in that number 90. next i'm performing a split action i'm splitting that string by a space why am i splitting a string by a space because if i head back to my subject it is help desk space ticket space the number 19. so now when you split you get an array so i've got an array of three strings help desk ticket and 19 why because i split it in that format now once i did that once i was able to split it the next step is i am actually going ahead and executing another function that i showed you earlier i'm getting the array sitting at position two y position two because this is position zero this is position one and this is position two right i'm just using my same concepts that i applied earlier so i get that number 19. also this is of type string you see this double quotes around it that's a string i need to make it into an integer so what do i do just use the integer function and encapsulate it with an integer that's all i had to do so it looks a lot of work yes it is but in order for you to pass strings you need to understand how you perform the different actions right how do i grab that node how do i split it based on the different elements that i'm interested in how do i grab the number of my node how do i convert the string to an integer four expressions and one these are this is a combo type of an expression a little bit more advanced but that's what i had to do to grab that ticket number and once i have that ticket number everything else after that is literally seamless because i'm storing it in a variable i'm just going ahead getting the sharepoint item based on that id and then just looping through the attachments that i have as part of my email and starting to upload them one by one to my sharepoint list man man it's so good i love i love how like so it's it's if you know this stuff if you if you understand json how it works this looks so easy and and i just love how you really can just methodically go through it and lay it out you can tell that you completely understand the system and the way that you communicate it makes it very understandable i can see why everybody was so ravenous for a third episode of this because like uh to be honest like you're teaching me right now as well all of this is new information for me as well and so uh i'm actually very excited because i feel like there's a couple use cases where i can already use a couple of these things okay all right you say you so i think we have one more you got one more use case we have one more well it's uh the third use case is actually uh just another example of how you can parse through things okay one more use case cool this one i've kept it relatively simple so it's not getting data from any connector as such but you can think about the use case here let's say i receive an email and this is what my email body looks like right here right many times email body is free from text many times right it's just free form text that users put in data and my use case here is let's assume i get an email that looks like this in this right i have assigned by raza durani on this date and this time now let's say i'm interested in grabbing certain pieces of information out from this text how do i do something like that okay so in this case the first thing is i'm again using a split function and the reason why i'm using split is because i'm trying to split this text by what by a new line character because i want every each and every line to be a separate item in an array so i can handle them one by one nice that's the first thing i need to do now in split there is no way for you to define a new line character yeah i can define a space but how do i define a new line character well one expression for this as well this expression is called decode uri component and this is the character code for a new line component or for a new line character whoa okay cool i never this is this is way beyond that's awesome okay so again uh for for folks who who understand character codes this will they will be very familiar with this if not when you want to work with the new line character just just use this formula uri component percentage o a and just use this and this will give you a new line object and right here i'm trying to split my output of this action which is my email body think about it as my email body and splitting this with that new line character now once this runs i will receive an array an array of what an array of all of these items individually once i get that array next step this is something i showed you earlier in the demo as well i am using the filter function so i'm using that same flip split function here remember filter array needs an array it needs a collection this is just a string by splitting it i get my collection once i get my collection the next step i'm using is i'm checking to see if the item in the array starts with assigned by maybe that's what i'm interested in i'm just interested in things in my email body where it says assigned by so i'm checking to see whether the array contains anything that starts with one another function assigned by remember i'm using the same item property again if that is equal to true now please note i notice a lot of folks making this mistake true true this is actually text this is called true as a text starts with as a function returns your boolean value true or false i need to compare this to a boolean when you want to work with boolean values you have to go to expression and plug in true or false so there's a difference between typing true which is a string and using expressions so in this case i'm actually checking the boolean value now this filter array will look through this random text and search for all those items that begin with assigned by there's only one so it should grab this line for me once it grabs that line for me the next step what i'm executing is once again some little array parsing i know there's only one line and i'm probably just interested in that line so what do i do i use the output of my filter action and what is this give me the first item of my array why zero no question mark that means i'm always expecting that value to be there so may not be safe best practice i purposely did this put a question mark in here okay and then how do i grab additional data points maybe i'm interested in the date more expressions more expressions more expressions you split get the array splitted by commas get the first node split it by colon get me the first value why am i doing all this because this is the structure i have in that string so however you have your data defined you can pass through it based on all these powerful expression formulas that are available now let's go ahead and run this and see this in action okay running this all right so first things first here's my new line character you see it put the new line based on that formula that i put in next thing this is my text that i get sample text let's say it comes from email it comes from your data source of record could be anywhere next step remember my split function i was splitting by what a new line character now what do i get i get an array an array of what an array of strings so you see every line including the space is being put out right here in the array and how do i know this is an array guys the square brackets remember notations then i'm filtering my array what did i filter by where the text begins with assigned by so what should be the output just one item again in an array you see the array here's my item it's the filter next step grab me the first item of the array which is a string now notice i don't have the array symbol around it it's different this is an array then i wrote the formula to grab me the first item so it grabs me this and then i wrote some additional expressions to just get the name of the person whom the task is assigned i wrote some functions in there and i got my output which is i could have easily got the date maybe that's a task that i want to create in planner you can use the planner action grab the name grab the assigned date due date assign toss and plan man i feel like i need to i need to breathe i'm like wow i'm hot holy cow that was wow raza man that was incredible that was really really good i mean so many great tips along the way all the new skills and i love how you consistently went back to why the bracket here because it's data what's that mean it's right it's inside the array breaking down objects and all of that man wow wow okay um i am going to go ahead and leave everyone with a couple of thoughts so first things first go follow reza you thought this was a master class he does this all the time go check out his youtube channel go follow him on twitter and i'm also going to put the link down below for his masterclass if you want to sign up and and and get to pick his brain and learn all of this to a greater degree it's going to be an amazing opportunity for you it's limited spots uh i would act right away and get in so that you can you can have this experience i'm uh i'm blown away man thank you so much for being here thank you so much for putting this in a way that's so understandable i i know the effort it takes to be able to compartmentalize these thoughts and and present them in such a way so really appreciate you being here and put it in such effort to make such a high quality presentation and this this was epic thank you john thank you for giving me an opportunity to come on your youtube channel and give me such a great platform to actually showcase these these different scenarios so thank you as well my pleasure all right you guys know what to do click like click subscribe go follow raza and all the things check the description we're going to have lots of links i'll even try and have him put some of these uh expressions in text form so you can easily copy them out we'll get you hooked up so go ahead check it out go follow raza much love from me everybody i'll see you in the next one
Info
Channel: Jon Levesque
Views: 7,947
Rating: 5 out of 5
Keywords: jon levesque, jon levesque microsoft, power automate expressions reference, microsoft power automate expressions, jon levesque microsoft flow, microsoft flow expressions, learning expressions, expressions power automate, expressions microsoft flow, expressions intro, introduction to expressions in power automate, introduction to expressions microsoft flow, expressions, wdl, workflow definition language, logic apps, logic apps expressions, functions, power automate expressions
Id: C52brz28poU
Channel Id: undefined
Length: 46min 54sec (2814 seconds)
Published: Mon Sep 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.