Power Automate Tutorial - Expressions 101

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Applause] [Music] what's up everybody welcome back I'm here today with my friend razor Durrani biz apps MVP how you doing sir hello Jon I'm doing good how are you I'm doing well I'm doing well I understand you're on a doubleheader today did a webinar this morning and now joining me to do a video thank you for that absolutely enjoy the webinar in the morning and now more excited for this one awesome awesome and so today Raisa is gonna do something that has been long asked for that I get requested all the time and I am not really able to do because I'm not good at them myself and so raises here to show us expressions 101 I'm excited for that sir so without further ado I'm gonna go ahead and let you introduce yourself fully and take the show away absolutely so hello everyone I'm Reza Durrani I'm a Microsoft business applications MVP I am also a principal consultant and I work at an organization called catapult systems in Houston Texas I will go ahead and get started with today's session we're trying out backgrounds today you notice we got minecraft backgrounds pretty fun you know change it up a little bit so let's begin with today's session on slow expressions 101 let's do it let's do it so though let's begin with what are expressions first and just like John mentioned that expressions is something that gets frequently asked about I am a power automate community super user and as part of the community I'm very active on the forums one of the most common questions that we get in these community forums is purely around expressions because expressions is is a language that you need to learn you need to understand and the more you play with expressions the more familiar you will get with expressions so let's get started with what are expressions first expressions and flow are a set of functions that can be used to perform any specific action you require within your flow some very common apples are listed right here string manipulations working with dates converting data types performing logical operations mathematical calculations and so on so forth so the moment you run into specific scenarios where in the existing actions do not suffice you have to start thinking about expressions so so razor in plain English I'm gonna help out on a couple of these things so manipulate strings what does that mean that means change text a string that's just text and then working with dates obviously that's like dates on a calendar converting data types maybe we want to take a string value and convert it into a number type which is an integer right and then logical functions as well that allows us to change the data to manipulate it in some way to cut it up in some way to make a decision and so just in plain English that's what a couple of those things mean absolutely alright now that we've looked at what are expressions now let's look at the anatomy of an expression now in this example that I've given right here I have a very simple expression and I'm using a function inflow that is called replace and replace as a function expects so this is my function called replace replace expects three parameters okay that's the behavior of the replace function the first parameter is the text your original text your string the second parameter is the text that you want to search for in your original string and the third parameter is the text that you want to replace the old text with so if I need to write a very simple expression like this if you look on the left hand side in the screenshot of the expression dialog we are leveraging the replace function I have a text and the text says the old world I am replacing the word or by the word new and if I was to run the flow and when this expression would be evaluated the output would equate to the new world basically replacing the world old with the word new because that's how I have gone ahead and framed an expression this is a very simple example but the goal here is to understand the animal the anatomy of an expression an expression basically will have a function and it can have one or more attributes associated with it those are your parameters and that would depend upon the type of function that you call within slope now that we've broken down an expression and we've understood what comprises of an expression let's look at the different types of expressions that are available in flow so the first type of expressions are the basic expressions which are basically expressions that constitute of one function with one or more parameters and we have already looked at this in the previous example the same replace function is right here and why is this a basic function because I'm just leveraging one function you are called replace I'm just replacing my text we have another function known as concat which is basically the concatenation operation it is used to stitch strings together and I am concatenating the words today is with UTC now which actually is also a function which prints out the current date and time in UTC format so both these examples are examples of expressions that are basic in usage the next type of expressions is advanced expressions and advanced expressions basically involves more than one functions that are plot together for a peculiar use case scenario now if you look at the examples that are provided right here I am leveraging the same string concatenation function again I am concatenating the text today is this time instead of directly utilizing UTC now is me the current date and time and UTC format I am actually going ahead and formatting that as well by leveraging another function this function is called format date/time and it expects two attributes the first attribute of type date and I am providing UTC now and the second attribute is the format that you want to leverage for this date field and I'm leveraging the month day and your format right so in this example again if you look at the anatomy of an expression this is a function it expects two parameters the parameters are strongly typed so if it expects date you have to provide date that's how expressions work if the parameter expects string you have to provide a string variable attribute to it so this is an example of so these are some examples of advanced expressions to this gray now that we've looked at the different types of expressions let's figure out where can we actually go ahead and plug these expressions in our flows so there are three places where you can use expressions which basically means you can use them everywhere and flow the first one is actions expressions can be used in any flow action so in this example right here as you can see I have an action that gets items from a SharePoint list and I have provided a query in my action which says get me all the items in my list where the activity date which is a date column and SharePoint is greater than or equal to a peculiar expression that I have plugged in and this expression looks like this once again there's a function the function is added days which means and it is to a particular date the date that I have provided is UTC now which is the current date and time and I am subtracting seven days from the date and the reason why I am subtracting seven days is because there is no function known as subtract days subtract days there is only a function known as and days and the same function you can leverage for both use cases and the documentation around these expressions will help you and guide you to understand all the various use cases around the different functions that are will yeah that that trip me up at first like the ad days - doing - in ad days I was like wait a second where's the where's the remove days hey so he can use expressions and actions we can also use them in conditions right so whenever you have a condition statement in your flow you can plug your expressions in there as well so for example I want to check to see that the length of the response that I get from a previous action and flow is greater than 1 or not so I can check a condition like that the third option is trigger conditions our expressions and he knows oh yeah it breaks if we did a video about this yes we did so so we don't have to spend too much time here if you guys want to learn about trigger conditions go check the description there's a link to that video that you'll learn all about it alright that makes it really easy go to go and check out our video yeah and finally before we head over to the demos another important thing to understand is that the expression editor in flow has two flavors as of today flavor one is the classic expression editor which is highlighted right here on the top and in the classic expression editor there are certain things that you need to be aware of number one this editor is currently generally available so this should be used in your production scenarios second the expression window or the expression dialog has very limited space so as you can see I'm highlighting this right here with my marker mm-hmm also if you want to plug in data from previous actions of your flow leveraging something known as dynamic content in your expressions what you would have to do is right at the top there's this tab experience so you have to click on dynamic content it switches over to dynamic content you can click your values and then head over back to the Express to make a change to the expression so you have to be aware of the fact that you are in the respective tab either dynamic content or the expression yep and one thing that I do not like about this is my fourth point which is every time you make an update to the expression and the old expression editor you have to click on the ok button or the Update button if you click out of the expression editor you will lose the expression that you plugged in into the dialogue yes the the old editor has has many pain points it's a it's a lot more reliable than it once was but it is still not as cool as the new experimental version that's our next part which is the modern expression editor I'm calling it the modern editor this is now available as an experimental feature I will show in the demo how you turn this feature on but you need to be aware that this is experimental and when you turn this on you turn on every other experimental feature that's available and power automate there's only a couple and they're all pretty good so it's not a bad thing but just to be aware also in this expression editor the first big takeaway is the expression space is large so as you can see in the previous classic editor we just had a very small box to plug in expressions and many expressions who used to get long it was very difficult to evaluate the entire expression in one view now with this new box that's made available to us you can plug in really long complex expressions the other advantage of the new expression editor is the dynamic content is also available within the expression dialog itself so you don't have to switch between tabs while jumping back and forth between dynamic content and expressions and the biggest takeaway for me is if you click out of this expression dialog it will save your expression so you won't lose the expression that you plugged in there is no need for you to click on any button in order for you to save your expression that's pretty nice that is there is a good change I didn't actually realize that I didn't think about that part of it that's pretty nice now we head over to our demos oh it's demo time I feel like I need a sound I gotta hit like a sound board bump demo time alright so we are now in flow and within flow I have already pre created a few flows for this demo purpose in the first demo we are just going to cover the expression editor because I want to compare the two editors in motion so let's go ahead and edit this flow now in this scenario I have a very basic flow that gets triggered manually so this is a button flow and in this flow I have a very simple composed action what is a compose action a compose action is an arbitrary object that gets created in flow and you can leverage it throughout your flow in this scenario I am just leveraging it to create expressions to demo expressions right now it's an empty box you just fill the empty box it's just an empty box let's go ahead and actually create this empty box so I will go ahead and search for compose and all I get is this empty box that I can plug in hard-coded data or plug in expressions now in this scenario I am in the old school classic expression editor and right here as you notice the moment I click on and on a property within an action it opens this dialog on the right hand side now within this dialogue I have dynamic content where and I can dynamically pick attributes prior to this step in my flow and then I can switch over to the expression dialog where and I can start plugging in my expressions right so for example if I want to plug in the replace expression I type in replace and I start plugging in my function right here yep as you can see the dialogue has very less space and I have to click on the ok button so if I start typing my expression and if I just click out I lose my expression okay so next we are going to look at the modern expression editor and in this scenario I will go ahead and once again create that same composed action which gives me a blank input where I can plug in my expressions the moment I click here you will notice a difference I did not get that dialog feature that opened up in the classic experience which had dynamic content and which had the the expression dialog rather I got a new experience right here known as function which is the expression editor and if you click on this this will now open the new expression editor experience the advantage is here number one you see the expression dialog is large for you to plug in extremely complex expressions number two my dynamic actions are right here within the expressions and Dax itself so if I pick this it will just plug in my expression without me having to even understand what how the expression syntax works nice that's for dynamic content another small thing but I really like this feature here as well you see this option right here it says list of functions this basically lists out and if I click on this this takes me to the reference documentation and it lists out every function that is available for you to use as part of flow expressions awesome so if you are streams yes what we needed to link this anyways so this is perfect this is perfect right the modern experience has this nice little option that I observed which says list of functions love it so do check that out if you want to go ahead and start learning about the various functions that are available as part of expressions now let's go back to the expression editor and now let's go ahead and plug a very simple function in this expression dialog okay before we go there how do I get this expression dialog how do I get this modern expression dialog just go to settings view all power automate settings and make sure that the experimental features is turned on please note this is on a per-user basis so me turning this on does not turn it on for my colleague this is on a per user basis yeah all right heading back to my dialog for expressions this time we are going to use the replace function now what I want everyone to understand is you do not have to learn all the functions by heart what you need to be aware of is that there are functions that are available and here is the entire list and the beauty of the functions is they are categorized and the article clearly categorizes all the functions so if you're dealing with strings right now I'm dealing with strings I just want to replace a character of my string with a different character click on string functions this will list out all the functions that are available you do not have to get confused whatsoever I am looking to replace strings there's a function right here called replace if you click on this this will take you and show you examples as well as to how you can go ahead and leverage this function with documentation clear documentation given out right here including the parameters including the data types of the parameters including what these parameters do heading back to the flow super useful very useful heading back to the flow now as I start typing my function notice how intellisense is going ahead and actually representing all the different functions that are available as part of that texted I'm entering so it clearly says there is a function called replay so I can just pick this I can open my function now notice it clearly says that this function requires three parameters write your text the old text and the new text now if I click out write it has gone ahead and place that function right there so I do not lose the work that I did that's the beauty of this modern editor as well that is nice if I click back here I can go ahead and start plugging my expression so let's say my expression says the old world right that's my original text yeah now once I plug in my next parameter once again look at how the intelligence is guiding me through I am not coding anything I am NOT going ahead I don't have to buy hard anything the experience itself is self-explanatory now it is asking me for text which is of type string right so I'm going to go ahead and type my text which is old and type my text which is new and that's how my expression looks like now let's say while typing you made a mistake everybody is human everybody can make a mistake so let's say I made a mistake and I forgot to close the bracket at the end now if I click out the beauty of this expression editor is it really tells me that there is an error there is something that is not right with this function that I have just plugged it so I've got to go back here I gotta go back there and I have to go and make the fix currently the expression experience is not too intuitive to tell you exactly where the error is but it will tell you if there is an error in your expression or not mm-hmm so the best way to go around it once again is to read the documentation will clearly guide you as to how many parameters what are the type of parameters how is the syntax of this expression supposed to be so make sure you get all of that right so once I plug in my correct expression as you can see it clearly highlights here in blue that this function is correct this expression is ready to use and now if I go ahead and if I run this flow so this flow has executed successfully if we look at this action you will look at the output right here which is the new world and how did the word the new world come across that's because I use the replace action to replace the word old with the word new in a very very simple expression to change my text in this string now if we look at some other examples right here this is the same example of replacing the text I have another function right here which is again an expression this time I am concatenating the string today is with a date UTC now right and if you observe the function again as I'm typing my function so let's go ahead and try and plug this entire thing again so if I type concatenate and if I open the function once again if you go to the list of functions right here and if you go to string functions there is a function right here called concatenate so you can see what these functions do for you and then go ahead and accordingly plug in your expressions and once you plug in your expression and once you run the flow so I'm going to go ahead and run the slope and this is a very simple function or expression that I've plugged in which says concatenates the words today is with the current date and time in UTC format and that's exactly what this expression has done nice alright easy yeah easy but there's a problem with this specifically in working with dates right yeah nobody actually tells time like that nobody email that goes out that tells you your task is due at this date and this time yeah you know try and figure out what the T's and the Z's mean in your time code a so the important thing to understand is that flow understands dates only in UTC format no matter how your system of record stores it so when I plug in data from SharePoint it will represent the date and time to me in UTC format if I'm getting it from sequel same scenario your flow understands dates and times in UTC format part when you are sending email notifications when you're sending tasks do reminders you would like your dates to be formatted right yeah totally now let's look at a scenario like that and let's see how expressions can help us achieve that okay so I have another flow in this case and in this scenario I have three different expressions written because I want to prove how the different functions guide us through the process of creating an actual date and time in a format that is readable by my users plus that is in the time zone that I desire it to be okay right so the first expression is the same as before I am just concatenating a string with UTC now so this will put out the date and time and UTC format the second expression once again concatenates today is this is a standard string but this time instead of directly leveraging UTC format I am using another function known as format date/time now when did this function come about go back to the reference guide again right go to data time functions and you have these loads of date and time functions that you can play with right there are so many options that you can play where there are string functions that you can play with there are many functions available that you need to learn and one of them is known as format gate time and all it expects me to give is the date and time and the format that I want to specify it in and this format is also given in the documentation so I've gone ahead and plugged in my format now although this will work and format my date and time and a more readable format than the previous experience it will still showcase the data or the date in UTC now time right so if I want to convert it into the timezone of the user I need to use another function and these are classic examples of advanced functions where and more than one functions are leveraged in one expression to come across a desired output like in my scenario my simple output is get me the date in Pacific time in a peculiar format yeah this is how the expression looks like and so and and all this is doing is kind of saving you time in steps there is flow steps actions that allow you to convert time and move those outputs but what razors showing here is how you can very quickly just take two of these actions and snap them together and avoid having extra steps in your flow it actually makes it a little more lightweight if you can do it this way absolutely and in this scenario all I have done is I've used another function once again the expressions guide the link right here list of functions will provide that to you there's a function known as convert from UTC all you need to do is provide the date and time in UTC format which is the basic format that flow understands and then plug in your specific time zone right here and you're good to go nice now if I go ahead and run so nice of you converting to my time zone oh that's right I keep forgetting that that's right so let's look at the outputs of all the three actions right the first action gives me I'm going to try and zoom in further so the first action gives me today's date in UTC now format nobody would like to read this for sure yeah yeah the next thing gives me the date and time in a more readable format which says Friday May 15 20 27 49 p.m. but this is giving me the date in UTC time this is not my specific time zone right now I'm in Pacific time it's not giving me the accurate time zone yeah and when I use the third function this time it was able to give me the formatted date and also it was able to convert it into the time zone that I specified in that one expression yeah see and now we're giving away secrets everyone knows that we recorded this video a couple weeks earlier so the thing about expressions now as John mentioned right there are actions available in flow where you can read data you can start you know adding or converting dates or you can convert it from one time zone to another or format your dates yes there are actions available and yes the flow team will keep adding new actions to make things easier but if you use the expression syntax you save on the steps and your flow your flows look a lot cleaner that's number one and number two once you learn this expression language any scenario any scenario is possible and when future videos when we will go to flows 201 and 301 which I'm hoping we get to there mr. John when we get there I am really hoping that when we talk about more complex scenarios you will realize how important expressions are to avoid loops to avoid multiple steps to get to the same desired output absolutely yeah it's it's definitely super valuable so now I think you know there there are the steps like like Razer said the flow team will continue to make those but just understanding this not only allows you to save steps but also it's gonna give you some extra tools in your repertoire because what you're gonna find is oftentimes things aren't gonna line up you're gonna need to turn one data type into another data type or you're gonna need to convert something to different ways to get it where you need it or or you're gonna have to do checks against date and time which really require a lot of things like which really require a lot of the skills you learn from understanding all of these expressions yeah cool man awesome so I think that's it for our 101 right we're gonna stop here and we're gonna we're gonna save the rest of the goodness for a 201 absolutely with a little bit of homework for our viewers I would like you guys to go ahead and try out the new expression editor try it out give it a shot try out a few basic functions the ones that I just demoed maybe just try these out and let us know in comments how did you how was your experience in working with expressions and so love it that's that's great perfect I like it given out homework baon told as Donna would say right awesome okay well you guys know what to do check the description we got a lot of info for raises down there and he's got a YouTube channel he's got Twitter he's doing cool stuff all the time go check out the trigger conditions video as well that's gonna teach you how to save flow runs and look out in a couple weeks hopefully we'll have an expressions 201 video coming at you raisa thanks so much for joining me man really appreciate you being here as always thank you John time thank you for having me once again on your show awesome all right guys much love from me click that like button click that subscribe hit the bell so that you get notified and we'll see you in the next one
Info
Channel: Jon Levesque
Views: 21,636
Rating: 4.9615383 out of 5
Keywords: jon levesque, jon levesque microsoft, pwoer automate expressions, 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
Id: k-yIhdseTQE
Channel Id: undefined
Length: 30min 52sec (1852 seconds)
Published: Tue Jun 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.