logo

NJP

Exploring Dynamic Flow and Get Flow Output Logic in ServiceNow Flow Designer!

Import · Jul 24, 2023 · video

hello and welcome back to the channel in this video we're going to take a look at Dynamic flows in flow designer what are they when you can use them and more importantly we're going to dive into the servicenow platform and set so up [Music] okay and we're back with another video this time it's going to be dynamic flows in flow designer but before we get too far in I just want to say a massive thank you to anyone that's dropped by to watch this video or have subscribed however not all good news people the YouTube stats tell me that 90 of you that are watching this are not even yet subscribed you know what to do let's Dive In okay so this vid is going to be slightly different right so I'm going to take you on the journey with me the dynamic flows is something I've heard about before but I've never actually used in a real-time scenario however colleague that I'm working with right now in a project came to me the other day and said hey this is the solution I came up for with the story that we're working on and it includes Dynamic flows and I was like wow that's genius genius but yeah it seems so simple so I thought having not used it let's use this video for me to I guess do the hard work for you right now let's take a look so we're going to know in the servicenow docs and then I'm going to take a look at there's an example that I found on the servicenow docs that they want you to build so I guess I'm gonna do the hard work for you so so or you can join me and we'll do it together but I'm going to try and be quick this is why it says Dynamic flows flow logic catchy identify and run a flow or subflow dynamically by using runtime data okay build templates to provide expected inputs for dynamically called flows or subflows so we build a template and we can call it using runtime data okay I'm going to skip out some of the bits because it'll be quite boring but you can go and I'll put a link in the description you can go and see this stuff for yourself let me scroll down to use Dynamic flow add Dynamic flow so that's flow logic okay the template for dynamic flow can be a flow or subflow got that point the templates in bulb must match the inputs or any sub blow that you call that a lot of flow words in this after you build a template consider copying it to create a case we're going to copy something let's just scroll down yeah for our design considerations okay use Dynamic flows if you have multiple subflows with some similar functionality ensure dynamically called subplots input match template we've just mentioned that use the correct context when getting flow update so context record you need to identifies the flow run okay so I can tell we're going to create a template we're going to call it using um flow logic so we're going to call this this template and they've got similar functionality and on a border reading the docs go read it yourself right let's crack in crack on evil okay so let's just get started with the example so we're going to go through this it's called get started with Dynamic flow and get flow output okay so that's another kind of activity Dynamic flow is one get flower outputs is another so that's two that you have to use together I'm guessing uh we're gonna go through this uh I'll put the link in the the description follow along or um or watch or do yourself um so let's just get cracking okay so I've got my PDI and let's flip that over to another screen so I can see what's going on okay I will read this out navigate all right okay we're going to create an app Studio so first of all we're going to create an app I'll edit this so it won't take as long when we're loading and we'll create an application called uh Cloud instance provisioning apparently okay let's do that then let's get started Claudius that's provisioning uh or they say in the roles enter flow designer or admin let's just put admin should we put it in scoped oh no let's do scoped huh okay rolls we'll just have admin or I'll tell you what okay okay so let's let's do it but right so flow is on okay loaders on a roll continue I might go too quick here classic continue and we need to create new table okay creating table from scratch create table from scratch that's what we're doing um and we're going to create two new tables for your application add the following Fields Right add field okay so I think that's it right that's table one oh did we name the table oh no right okay so this is table one we're calling it cloud and so this is about Cloud provisioning that that instance there's a saying about extensible or access uh we've got admin anyway let's go okay take it well edit right okay hang on with this what's this continue okay no we'll create another table so table number two is called um I'll just copy that for later remind me okay we've got and that's a URL okay we're good to go and that's the nag fired instance provisioning request so we've got two tables the first one we're creating is called Cloud instance the other one is cloud instance provisioning request and this is about loud provisioning request I would have thought so we've got a great um possibly a flow and some subflows which we're gonna call dynamically possibly based on that choice list maybe I know are we done with tables let's look yes done with tables again I'm following the application build just to flick over and just tell you where we are we're here great subfloat template right so let's go back uh restart that mate great boom with apps okay so that's our app built right next line on the business logic process Automation and integration so oh that sounds interesting um should we do it should sign a bit basically it's logic I'm not going to it wants me to get a flow designer let's get a flow flow designer in the photo designer landing page main had a quick subflow yeah we've done that um do we just want to create a new subplot yeah right okay so we're creating a new subflow don't know why that was taking me there on the subplot property screen which is this enter the flow name which we're using is called that it's inside our application correct yes in the name field all right okay it's called subflow name not name um and click submit doesn't want me to do anything else no category no roles okay we're doing that clicking submit under the inputs and outputs yep what are we doing here under impossible select the plus icon to create two inputs for your okay we're going to we can do that we can do that right there's two we've got one call requested bike question Buy um type is reference user table did we just did this on our table didn't we okay for reference user table and then we've got this requested instance all right and that is a screen okay we can leave that like that select the plus to create one input for your subflow okay so we'll do that and then this is called instance URL um and this is a url url oh yeah I've got a type of URL okay click done Okay so we've created a subflow template which takes in an input requested by and requested instance type which are two fields that we've just created on our tables and the output is the instance URL so I'm guessing um the person is going to make a request there's a requested instance type so they wanna requested time of instance as you can return a certain URL well just stay in the obvious right okay select and add an action let's do that then um add actual logical subflow and then select action right from the list all right okay so we're going to Quick create a log select log oh it's there right okay oh it's there log in the data panel oh drag the data pills for the requested by here look and request instance type input you created earlier and drag them both into the message field okay one uh two okay no spaces or anything in the subflow header select save and publish okay we can do that so our subflow I guess for the purpose of this example the subfloat is really simple it's a template that outputs a log to the log files but it could be anything could be a task could be anything okay so let's have a look at that so we've created our template we are now on to step number three here you go so you can see create a subflow from jira cloud instead of provisioning requests okay let's go and do that in the silk flow header select the more auctions icon and copy subflow okay we can do that then we'll give it this name okay still inside the application and copy okay that was easy under the log under the log action oh okay under the log action we're going to create go away oh right we're going to create create a record lit create a record okay scroll then slightly create a let's not create a record we'll create record right in the table name select Cloud instance okay so we're going to create an gonna create a record on the table that we just created interesting uh and then do the following field so owner we'll come back and populate these in a sec owner instance type instance type instance URL I might just add these in and then edit this out you don't want to watch this instead okay and then we need to make these subflow inputs is requested by so the owner is requested buy so let's use it I'm going to do this way this time instance type yes the Innocence type if any of my people do things differently instance URL we're going to enter my company this is from the instructions by the way my company then select the data pill picker the subglow requested by name okay so that is going to be requested by name a bit weird okay let's go with it name name you're there and then don't forget this is Kira so it's going to be Dot atlassian.net okay so that's the instance URL build status um we need to enter in progress okay under the create action add another one was this okay so underneath here then we need to assign an output and again I'm just following the instructions so assign subplot outputs and under name we're going for instance URL and this data pill the data select the pill number two create record instance URL okay number two great record instance URL click done save and publish so what have we done there we've used we created a template before subflow template we've copied that and now we've got to fleshed it out by doing a create record for the create Cloud instance record which is a table we've already created and assigning a subplot output okay so what's the next thing we need to do I'm just again I'm just following these instructions the next thing is we're going to do exactly the same as we've just done create Cloud instance record jira we're going to do it for Salesforce so create Cloud instance record sales for the magic of editing there we go we've we've got a subflow for Salesforce so in reality the only thing I've actually done is copy that and then I change the instance URL to be salesforce.com again it tells you all this in the instructions that I've been following okay what's next so now we've so we've created a template subflow we've got two subflows one for jira one for Salesforce we've also created two tables as well don't forget what else do we need to do create a sample flow okay so we just need to create a flow don't over complicated servicenair we need to create a flow let's go in Vlog this one is called process Cloud instance provisioning request okay just click submit trigger we don't want to tour don't show me again skip tour right trigger uh created okay and this is our tablet Cloud instance provisioning request table and that's created done under actions click the plus button and aha now this is where it's all starting to come together flow logic this is it people Dynamic flow this is what we've been waiting for I hope you haven't turned up Dynamic flow here we go Dynamic flow now what do we do in here flow template this is what we're selecting so it says select the template that we've just created where is it uh oh no it's not on Google is it um on Google non-global right okay so I provisioning request then Blake bone great Cloud instance record ah okay there we go so it's got the inputs from that template that we've just we've selected before so the one that we created it says flight what do we put in here enter okay this is a string field right what does that say oh there's no hits right all right no heads okay so we're gonna end to create wired instance record space hyphen and then select the data pill picker yeah I can do that and select the trigger record okay what was that record created requesting instance type best it is let's do that type okay let's just go Through the Motions this is requested by so this will be requested by this will be requested instance type that's the same as what we've just done let's see this type okay so let's just digest this a bit so we're using the template that we created in the flow template we're calling the flow create Cloud instance record and then we're dynamically changing the last bit to be something that has been selected on that requested instance type and I'm guessing that was our choice no that was our string wasn't it I'm guessing that's going to be either jira or salesforth Force so the words jira or Salesforce are going to be added in there right let's continue okay under the dynamic flow logic add the get flow outputs logic here's the other one people you've been waiting for get flow outputs okay known here for float okay we've got flow template again so we go back to our template that we've created context okay Dynamic flow context so we go Dynamic flow content okay so this is how you get the outputs of that Dynamic flow so usually the outputs would be something that you drive on the subflow and that you can just access them when you just you know you just call a subflow right Dynamic flow we have to use get flow outputs hey that must be the difference under the get flower books create what's this um update record there is update record and it's going to be the record that created it's going to be this and the fields are going to be approved instance and approved status okay approved instance yeah flow outputs okay so we're now using get fire ah instance URL and then that's approved okay so we hardcoded that okay so let's just pause for a second and think about what we've actually done while you've been watching me struggling with my typing we've created an application for cloud provisioning we've created two tables okay we've created a bunch of fields on those two tables we've created a template subflow we've created two subflowers off the back of that subflow one for jira one for Salesforce okay both the same but the only thing that's changing is that URL we've now created a flow which pulls an action or a flow logical Dynamic flow which we can pass in values to call one of those subflows that we created for Salesforce or jira when we've got those we're going to update the originating request with an instance URL okay let's not forget we use get flow outputs as well so you may have seen that before okay so let's give it a test see how it works we click test on the pair and flow that is don't forget we've got subflows pair and Flow errorflow what we want to do here is actually create a record so I think the intention is is when we create a request record so cloudiest is provisioning request we put in through the requested byte it can only be one the instance type so we're going to decide what type of instance we want what cloud instance do we want the gr1 or a Salesforce one now this is free text at the minute you would obviously put that as a choice you wouldn't rely on someone typing it in but if we go for jira that word is going to be replacing the subflow that it calls do you remember when I did the action and then I'm guessing what's going to happen is when this test it guessing I don't need to guess I'm through it it's gonna give us the approved instance URL and it's going to say approval status approved okay but we're not really interested in that so that's me submitting it let's pick that we're not interested in that we're interested in the fact that it's called the right flow so let's go in there Okay so we've got the input is going to be the record that we just created we know that Dynamic flow okay jira okay here we go look this is what we wanted to see do we give it the flow template and then we dynamically created that flow name you remember that part that word jira was coming from what I just typed in rather than hard-coded here we go look dynamically dynamically con what Dynamics Dynamic flow context record jira okay wonderful and then we get the flow outputs and there it is atlassian right so let's just go and quickly just test just to make sure we'll do sales forces though this time hopefully yeah you gotta go for Abe Lincoln restaurant Salesforce okay boom Oh which one was that uh I don't know the other one 14 12. there's got to be that one all right let's run it should have put a display name on there really I'm just following the instruction service now okay so let's look at update record Salesforce here you go Salesforce or sales for um okay let's see if we can find it better up here get flow outputs oh did I not compute it properly okay the point is it's called the Salesforce one obviously if we go back to here let's just see create card instance did I not copy it right or is there too many characters let's have a look now salesforce.com it's ah I know what it was when I could that's that's bad when I created that field um instance URL field on the table it was only 40 characters long so it's cut it off at 40. created 120 does tell me to do 40 what doesn't even tell me what to do in um in the instructions but perhaps I should have just used my brain okay so that's that's interesting but it does actually does beg the question for me is if I didn't know about this what would I have done I think the answer would be for me anyway it's in flow designing you've got the flow logic if haven't you so let's just have a quick look we've got flow logic if so what you could say is if request type is jira trigger this subflow if request type BS Salesforce trigger this subflow so you could achieve this with multiple ifs um if statements throughout the flow um so I think Sue is now trying to kind of fill that Gap where you don't want to fill up a massive um flow or subflow as it were with a lot of switch or if statements so I think that's where the dynamic flow for me uh fills that Gap okay so let's just quickly recap on what we've learned today so service now had some documentation on Dynamic flows and it's a flow logic inflow designer it works with get flow outputs you need get flow outputs to determine what the output is of the dynamic flow for me it replaces things like multiple if statements who did I achieve it with if statements yes I could because I could say if requested instance type is jira run this subflow if it's Salesforce run this subflow and do multiple so I'm guessing servicenow have implemented this to replace those long list of it um if statements that you might have in a flow we've also learned that it may be painful for you at times to watch me go through this process and manually type out stuff all the way in which case I'm going to try and do a hefty edit on this video and make it a bit more entertaining so I hope you found this video useful if you haven't yet subscribed as I said before 90 of you aren't please consider subscribing it does like all the difference to the channel but until next time I've been Russ and this is service nerd

View original source

https://www.youtube.com/watch?v=Ju586arMFdY