NOWCommunity Live Stream - Topical Deep Dive - Custom Flow actions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] good morning good afternoon good evening wherever you are and whenever you are welcome to the community live stream this is july 23rd 2020 my name is chuck tomasi senior developer evangelist at servicenow and i am here to bring you an episode on creating custom actions in flow designer because sometimes you don't always have what you want and you need to make your own mousetrap or whatever it is that you need to make in flow designer i'm here to help you get started doing that understanding how that's done and taking the skills you see here they're inspired largely by the community that you see behind me i'm on there all the time looking for ideas and searching for answers and seeing if there's a common thread so that you can take those i'll give you the answers behind those answers you can take those skills become a more effective service now administrator and developer let's continue on i see lots of great people checking in some familiar names on the community mark is checking in john oh man it's great to see you if you're watching this on youtube don't forget share like subscribe notifications all that good stuff if you've got questions put them in the comments or in the community this video is posted back into the community so it's sort of a as fred luddy calls it a selfie self-eating watermelon i've never heard that metaphor before he mentioned it but it is what it is and we'll take it for what that is a video about the community that ends up in the community anyway i'm getting too deep into it i don't have any inception moment there also do this on twitch if you want to watch there you're more than welcome although i don't monitor the comments live like i do on youtube and the videos are only around for a couple of weeks but if that's what you're after you've got an option on twitch as i mentioned a lot of these are supported by the community if you've got a question beyond you know hey what's the input various input types or what's the difference between a and b when you're choosing an output or how do you do this with the script please leave that for the community those in-depth questions those questions that are not on today's topic are great subjects for community posts please post those to community.servicenow.com i will probably not answer them live this isn't a live fire show but i do want to keep track of your interactions in case you have questions about what i'm talking about today custom flow actions so dhruv good to see you swapnil aiden sam everybody's checking in great to see everybody the developer community is over at developer.servicenow.com if you haven't done so already i suspect many of you that are watching today are are part of the developer community but if you're not go over and get a free personal developer instance at developer.servicenow.com today i believe it is today you know what i'm really curious we should check and see if i can upgrade to paris this is this is uh the early access release date so if you haven't done so already or if somebody wants to beat me to the punch and put their answer in the chat say yes i'm on paris paris is our latest release early access is available july 23rd and there is a lot of stuff if you don't feel like reading through all the release notes i've got a webinar for you it's called tech now for developers coming up on july 28th at 8 a.m pacific time so that should give us enough expanse to reach our email audience and india and maybe even those night owls that are hanging out in australia go register over at bitly slash tn77 reg it's a it's going to be a fast-paced one these releases always are because there's so much in the platform on every release that we want to make sure we get it all in i'm not going to have a lot of time for demos but upcoming episodes looking at september october november those are going to be deep dives into some of the shiny new objects that we've got and then i can take some of the smaller topics maybe some of the apis and put them back into this show so there's always lots and lots of content to to to go through let's bring back i need to be able to do this in one smooth keystroke but we'll try it this way get that and get well you had that let's do that maybe that's what i wanted i will be writing an oh so small amount of javascript today so if you're not familiar with javascript and you want to learn more go check out the javascript series over at youtube on our developer channel bitly slash sn-learn dash js that will actually take you to community article and that can launch you into the entire playlist so look for that there if you want to get more into some of the low code and more in-depth javascript stuff that we've got um what else do we have i'll put any code snippets on github look for those over at that bitly link yeah i'm a bitly fanatic it makes it a lot easier especially when you're talking about community posts i really am never likely to read a cis id on this show i might read the last four digits but that's about it if you haven't done so already share this with some of your colleagues the free ebook over at that bitly link servicenow dash no code apps for dummies get them introduced to why the now platform is a great place to build their no code start that digital transformation make your cio happy that sort of thing let's continue on with today's lesson i think that's it i do have one more slide that's coming in uh we have a developer podcast that's launching soon so keep an eye out for that first episode should be dropping on the fifth i'll give you names and links and details i've submitted it to the regular podcast directories just want to make sure it's listed there so i can say hey go find it on all your favorite directories otherwise i'd have to read an rss feed link to you and that wouldn't be any fun so maybe i should make a bitly link for that too [Laughter] okay on with today's topic i think i covered everything yeah pretty much just looking over my notes see i have a checklist so i don't miss anything good morning sarthak ana palm good to see everybody okay i've got my personal developer instance behind me and apparently i haven't had a chance to log in yet today we had a minor audio detail just before the camera started had to resolve that so i might be a little little off today uh not seeing anything for paris early release on the developer site oh i must try developer.servicenow.com just to answer that question maybe it's coming later today i'm going to sign in must sign in oh i don't know if you noticed but there's a little badge at the top of the site as well you know every once in a while that comes up with the ui look up here discover the paris platform features that's techno so you can get it get registered there as well i think there's also a banner on the community on the side it should be under the developer community i know i'm just making a complete mess of this today on the developer community there's also one over here tech now team webinar paris platform features same thing click that you go to the registration page you get signed up you get the calendar invite the whole thing let's go to refresh status manage upgrade instance oh orlando patch 5. that's not what i wanted to see i wanted to see paris with the eiffel tower icon we'll get there keep your eyes out it's supposed to happen today keep your eyes out okay back to my personal developer instances i forgot to mention meetups a lot of virtual meetups i need to look at the calendar see what i'm going to next week or have the opportunity to flow designer okay flow designer if you don't know is our latest generation of building workflows the legacy workflow was great it's been out since 2008 gave you the kind of that vizio experience where you could drive activities but it it wasn't extensible enough to address requirements of today sound like applications you write requirements change business models change organizations are looking for digital transformation to get out into the organization they don't want to rely on i.t to do all of their development for them so you know the workflow although it looked easy from an end user standpoint you couldn't give somebody access to that because there there was no um segregation there was no delegated development capabilities for it there was often a lot of scripting and it just it had its time okay flow designer gives us a new easier to use interface to spell out what is the trigger this takes the place of scheduled jobs business rules many of them i won't say all of them but many of the business rules schedule jobs inbound email actions you can create different triggers and i am going to create a new action because sometimes as imagine you needed you need new tools in your toolbox that aren't available when you go and create a flow let me just look at my cls 323 and i will do a take a look at course deactivated i don't even know what i was working on here but uh random thing i could select a trigger so when a record is updated and i pick a table this is much like a business rule only a business rule i would have to either script a whole lot of stuff or do codeless for very simple things we'll say active changes to false okay that would be a trigger course record was updated and the active was changed to false therefore i will run the actions that are down here and i've got a number of actions that come out of box and i've built a couple here as well sample array i don't remember oh yes we did cover that a little while ago but um the servicenow core handles things like logging updating records sending an email very basic services that you can expect i've got a number of integration hub spokes turned on this allows me to use flow designer to communicate with third party services hey i want to go create an active directory user or go get me the groups that are available on the active directory or send a slack message lots of different ones in here and i can see there are a number of them that are not installed and we are coming out with oh so many more every month they these are released what we call out of band the band being orlando paris quebec rome those are six month releases these come out out of cycle you don't have to wait for a major release to get these integration hub spokes i'll talk about integration hub a little later some other time but let's say for example i want an action to get a system property okay so i go in here and i say property oh nothing comes up i don't have a way to get a system property but i like using properties in my applications because they allow me to change the behavior of what i'm looking for so let's go and make a very simple action i do this through action designer and i could do i could select one of two places do this this plus that's up here i wonder if i can zoom in on that for you a little bit the plus that's up here and i can say create a new action same exact thing as going to this menu over here and saying new action either way it brings up the properties box and i give this get system property give it a nice name that will show up in your menu you can optionally select a category there are various categories and what the categories do i'm gonna have to cancel this to show you what it does what the categories do is allow you to break these down into sections see how this one has default then attachments and email and service catalog those are the categories that are available now i can also create my own in the cls i've got just default so let's go and create one or something new let's go back there get system property and i really don't want to choose one of the existing ones so i'll create a new one new i'll call it system it's something the system does and 100 sounds like a good order i can always go reorder them later the application field is available to pick unlike many other records when you're creating a new business rule it will default to whatever scope you're in flow designer allows you to choose this is going to be you know what getting system properties does feel like something i want to put in the global scope make it available to everyone it doesn't have to be specific to my application and you don't need my application to build this so i'll put that in the global application you can put in a description get a system property by specifying here get the value of a system property and optional default value i'll show you why i'm going to send the default value now i've got the action designer in front of me and it says you've got nothing except inputs and outputs so what is it that i want to pass here's where you get into a best practice this should be very much like if you're scripter a function this is a small piece of utility that does something very basic it's really tempting to go crazy and say i'm going to pass it 15 parameters and make it flexible enough to do 17 different things and then i'll only need one action well it gets very complex to debug and maintain and test it's much easier if you stack these up in flow designer and say i'm going to get a property now i'm going to check the value of the property and make it logical in the flow and you make it more flexible so you have to build a few more of these but you have to do they're very easy to build okay just like functions if you've got a 600 line function you probably want to break that down because odds are you're going to need to reuse some piece of that later and don't copy and paste if you watched our webinar yesterday with david liu let's specify the inputs i kind of mentioned what you get if let's start with this let's start with this let's go to docs and i am going to i know that get property is a method of glide system gs.get property is how i would do this if i were going to write it in script so let's find get property or i can't spell today it doesn't seem to be in there uh glide system on the developer side interesting the api is not documented on docs it's documented over here this page requested unavailable because it doesn't support specific release version oh wonder what i selected anyway i'm on orlando down on the left we're going to go to get property here is how i would normally get a property okay gs.getproperty some value a named property and these of course are stored in the sis properties table which i almost always have a bookmark for because it's not a module and i could say if i asked for glide last plug-in it would give me this string i've got different types and i use properties all the time again as a way to change the behavior of my application in production if i want to change something from a 24-hour window to an eight-hour window i can do that change a property but i want to be able to let my flow access those properties so now my flow can change its behavior so let's go back here not here let's go back to flow designer and there's actually two parameters that i would pass to gsget property i forgot to point that out shame on me there is a key which is this name parameter here and then there is sorry about the window flipping it says alt which i think is a silly name but it's an object alternate object to return if the property is not found thing to remember about properties is gs.getproperty always returns strings so if you want to return the native type you're going to have to be aware of that if you want to use that somewhere else i'm not going to get into that in this example i want to make this a very simple give me a property if i don't have it defined this alt is if it's not defined i might ask for a property called uh latest album i listened to this system goes i don't even know what that is well if you don't know what it is let's return some value okay so i'm going to need two parameters one is the property name and when you name the action inputs okay there's there's going to be a couple of different things here there's action inputs and then there's the step inputs when you name your action inputs this is what's going to appear on flow designer when you pick an action and prompt for information so if i say create record notice the labels here table fields those are nice human readable labels we can make use of that in our action rather than saying property with a lowercase p let's make it human readable it's going to give it a name behind the scenes that you can use here that is a string and i absolutely must do this because without a property name this function this action really has no purpose so i apologize for the large font it makes me scroll back and forth to find things like create input if you don't see create input just back off your font size a little bit and you'll see it in fact i'm still zoomed in i think yeah so if you get too much zoom you go where's my create input do that or collapse your data panel using the little data panel collapser over here all right we'll get to the data panel in just a second we've already talked about it this one i'm going to call can i zoom in on that i can we're going to call this a default value which is nice that's a string but i'm not going to make that mandatory okay i've indicated what i'm going to pass in haven't done any coding yet but what i really need is to add a step so i click the little chevron right here alongside between inputs and outputs to say put a step here this is what i want to do next now this instance has integration hub loaded so i've got a a few options down here that you may not see and script is part of that integration hub so if you don't see script you'll know why you're going to have to turn on the integration hub starter pack i believe that's the one we want so what does that give me this gives me a couple of things i can tell it where i want to run i'm going to run it on the instance you could run it on a mid server i have yet to find out when i would use vanilla core javascript i'll figure it out someday i'm sure it's in the documentation i just haven't read it yet but in most cases that i've run into i'm running on the instance now i need to pass inputs to this script the script itself does not have automatic access to the action inputs think of it as like scoped variables i don't see them unless you tell me about them so what do i want to pass into this script step i definitely want to pass in the and this time i'm indicating more variable name type parameters so the name here is going to be whatever i could choose i could choose foo uh make it sure it's alphanumeric underscores typical good variable standards if you don't know your variable naming go back to whatever was episode eight three four i think it was episode four of the javascript series i'm going to call this uh key since that's what they called it in the api and give it the value i can either pull this property in here and it says yeah i'm going to use the action property i thought i said property name on that did i not say property name i did not say property name okay if you change them later be sure be very careful that all your other things are updated as well okay so key is going i could also use the data pill picker to go to inputs property name it makes them a much much more readable data pill when they've got good descriptions and i will say default value not just default default is a keyword you want to avoid variables that have the same name as keywords default value and it is going to have the default value here why do i care about that because this is where i'm actually going to do the low code scripting work and say r val equals gs.getproperty and thank you for the code completion now i specify the input as inputs dot and then the name up here key that's how it's passed in and the second parameter was inputs.default value and for whatever reason the code completion wants to put in the first parameter that i already specified that's it i've got my value now i need to pass it out of the script so it's like going out one level that's done with outputs dot if we can zoom in on that a little bit for you that's much better outputs dot ah i didn't give an output yet that's down here i need to determine what is my output called let's just call this property value i think that's just funny now this one has a label and a name so i can say property value with an underscore notice that when i camel cased this it did not camelcase the name for whatever reason i don't know what the logic is here who decided this but camelcase on outputs isn't very helpful however i can camelcase the inputs at least i hope so it's going to be a string remember i said it's always going to be a string we're going to leave it at that and the output yeah pretty much should be mandatory so now i take this variable name i'm still making things up as i go equals value could you have said outputs.propertyvalue you do this in one line sure i'm doing this for demonstration points i i have run into some curious observations i'm not going to say it works or doesn't work but i've i've run into crazy situations where i've tried to assign things directly into outputs.something immediately like build an array of objects on the fly didn't work so well so i build an array of objects and then assign it at one i'd like to keep my outputs all at the end just before it's done do all the settings so you'll often see in my code that i use some temporary variables kind of have the working spot and then i have the assignment spot just a good setup to assess your inputs like hey maybe this is an optional parameter and i should check whether i have one or not before i do this piece of code then i have the actual working part and then i have the output part makes it a little more easy to understand okay so there's my script step it's going to return a property value that i can see over here in the data panel and finally i need to pass that script output to the action output it's just finishing the job in the script and i've done this before i went there i'm done and i go back to my flow and it doesn't have an output i said what happened well your action still needs to have an output and this is done in a couple of steps the first is to define the variables and then it's defined the values of the variables so this is going to be my property value for the action see if we can spell that zoom in a little for you proper t value property value is a good name for it it is a string it is a mandatory and when i'm done defining the variable types i say exit edit mode it says all right great tell me what this mandatory value is and i can take my script value and put it in there now imagine many of my actions could have multiple steps and i might get some things from step one and i might get some things from step seven and i might get some things from step 14 to build the actions outputs always a good idea that's my simple action let me save that and as of i think it was new york maybe it was orlando no i think it was new york i'm getting my releases mixed up it was new york or orlando we have a test button you don't have to publish it and go to the flow and test it this is much easier i love this here's my these aren't in the right order i will switch those around for whatever reason those are backwards default value let's put chuck let's put instance name in here because i know instance name is one of the default properties that's on everybody's system if it's not you're in real trouble i run the test and it says i'm done now we go into the execution details it says here is your action it is completed it did these various steps the runtime value is down here on the details you passed me chuck i got instance name i give you dev79000 that's my developer instance hooray i know it's working if you want to check the details of each step you can down here look there's my step inputs here and here there's my step output again it seems like a trivial solution but now i've got an action to get system property something that wasn't available to me from a baseline instance once i believe it's robust enough i don't because i want those inputs in the other order i'm going to switch those around save i just want to test it one more time to make sure they're in the right order array i've got that let's test it one more time with the property i know that is not in there last album i listened to and the default value will be i can't think of which album i listened to last but we'll say journey escape why not escape and it's going to go out run gs get property and say i have no idea what that property is so therefore i will use your value which comes back as you can see with the runtime value that i specified because it couldn't find that property always a good idea to have default values now that that is working and i believe it is robust enough to put in production i click publish and uh late news from mark says paris release notes are available so i guess pdi upgrades will follow shortly awesome good to know let's go to servicenow documentation and look there's paris right here oh that's good news the future is on its way not soon enough for some of us my property is working excuse me my new action is working let's go put it on a flow so let's go action it was under global under system there it is and i can use my instance name let's say if you know what i'm going to fat finger it on purpose i type it wrong and i say no instance named i run that and notice i now have a data pill over here on the right that says property value which makes it sound like i'm going to have more taxes action log and we'll put in a debug statement instance name equals go to the data pill picker and get the property value save do the test test skips the trigger so i don't have to wait for my record to be updated but i'll pick one run that check the flow and both steps completed the output was no instance named i go well that shouldn't have happened because i know instance oh i typed it wrong here's the log output instance name equals no instance named now i can go back and debug it and say oops silly chuck you typed it wrong let's go get the instance name try that test it very fast pick a different one run it and now i have an easy way to get system properties instance name equals dev seventy nine thousand that's pretty cool let's make something a little more complex though as oftentimes you're going to want to pass in more than one parameter which we saw but you may want to get back something more complex than just here's a string okay great for a learning example great for system properties but i'm going to make a little more sophisticated action get here look up courses let's put this in the cls because it is related to my cls courses get a list of course objects found based on a condition we're not just going to put in something we're going to make a cool filter the input is going to be oh call it filter and i have a whole bunch of different data types in here one of which is conditions and if you watched my condition fields video a couple of weeks ago you know that i have to have a dependent table so that it knows where the fields come from this is using more of a static dependent so i'm going to tell it which table to look at to get the fields for my conditions because without a table you don't have any conditions because you have nothing to pick it goes am i listing fields for the incident table am i listing fields for the asset table and my listing fee i don't know what you want so i have to say i want them for my course table and that will put up a nice little filter tool for me let's make that mandatory or you know what it doesn't have to be mandatory no filter would indicate all records okay so let's pass in something different that's fun and i am going to do i could do this with a look up records here but i'm going to script this with a glide record just to do it a little differently because lookup records gives me things that i want to build myself this particular time so what i need is my filter which is going to come from the action input try that again inputs condition and i am going to do a fairly standard glide record operation our course gr equals new glide record and since i can't remember the table name i'll use last episodes constants.course table and cross my fingers that i actually have that in there maybe let's find out do i have a constant script include if you want to find out more about this one go watch monday's episode script includes constance cls323 does it have a course table no darn it let's go put one in there because i don't want to remember the 66238 i don't have to type it and if i give this to somebody else and they say that's not the right scope course table equals x you know what i can do constants dot scope plus of course ooh now i don't even have to remember the number anymore update that go back to my action designer now this will work constants.course table course let's check if we have a filter if inputs dot filter then course gr dot add encoded query because when i build a condition field it's building out an encoded query active equals true up carrot name equals some string up carrot it's building this encoded query string for me so i don't have to know any sql statements and i don't have to add these manually to say well did they want active or not and this also cuts down on my action having multiple different types of parameters do you want to check for just the active ones you want to check that's too many inputs let's make this flexible so add encoded query inputs.filter get rid of that i mean close that out then i think we're ready for the course gr dot query i'd like to build a list so let's go var list is an array and i'd like to build an object for each one of these well course gr dot next this would really be handy in a script include but i'm not going to do that right now this just feels like i should have a way to say go get me this filtered list of records and i'll take care of the answers later let's do list dot push i'm going to use the display value so i'm only going to push no no i want an object in here i'm going to return a complex data type so let's say i want to get the active field which will be true by default now let's get the actual value it's going to be course value active and if you didn't know the value that comes out of a true false field is actually a one or a zero so i'm going to compare that to a one and get a boolean true false out of this thing let's get the name which will be course gr dot get value name i can't remember what else is in that table so let's go figure it out cls cls courses uh order would be nice we'll just go with that we'll get the three things just so i'm not typing all afternoon order is an integer and again if i get something with a get value assume it's going to be a string so i'm going to parse the int of course gr dot get value order as a decimal number and that's my object then i'm going to push the object into the list all right pretty straightforward i've got my list now i need to expel it from the script so this is where i'm going to say outputs dot list equals list the other thing that would be handy to know is how many of these i've got because if i want to do a for each loop and there's nothing in there the for each breaks so i only want to do the four each if the count is greater than zero so let's also add this is a best practice that i learned the hard way count equals zero and then for every course record that i get increment count and i will also pass back outputs dot list count equals count there we are so i know i need at least one integer variable called count count count integer and that would be nice if it was mandatory also i'm not really sure if if it will stop if you say this is mandatory and your script doesn't give it to you i haven't experimented with that i i use mandatory sort of inconsistently right now and notice that i can create another variable here just by highlighting just under this and i want to make a complex array of objects i want that list which is an array and it has all those attributes in every one of those from every one of those records so this is going to be my list which i called it list this name and this name list and count have to match this the array is going to be excuse me the output type is going to be an array of objects and notice that it does this indent thing now i specify what it is this is going to be a course and i like to keep my names all lowercase it defaulted to uppercase for whatever reason it already knows it's an object because i said this is an array of objects so i can't change that data type what i can do as soon as i get done sneezing here maybe it'll go away on its own i hate those threatening i've got course i'm going to add a property under course one of which is going to be what did i say active name and order let's take these in order active active is going to be a true false oh it was right there then i add another one just under here or i could add it here same place if i go up to the top and add a plus it's going to add one at that top level i am now down into the list course active so i want one directly under here which will be named name and going to also make a order order integer there pretty easy to build that's from the script now oh what i could do is it available here i don't see it here rats take a look at the feature for templates rather than typing this over and over and over again because if you're passing this object into some actions and out of other actions it gets really tedious especially if you've got nested objects and lots of properties you can make a template out of those and then just say just use my template but since this one's not too bad i'll show that to you another time okay whatever's making my nose itchy i don't like it now that i've got my script step run and i've created my object i've got my properties let's pass those back before i forget something's wrong with my zoom here there i'm going to save we did a lot of typing action was saved successfully now i need my action output which is going to be account count integer it's going to look an awful lot like what came out of my script but that's no coincidence integer and i do want that to be mandatory the action will not work if it doesn't have its outputs i'm also going to create the oh and i can add a default value here if i don't have one already i could say zero is my default value don't forget about this little up down thing this is going to be my course list again i don't have to name the output variables exactly the same as the step variables like these are going to be readable on the data panel in the flow so make them human readable i could call it internally list again it's going to be an array of objects and this is where i could oh i missed it there was a template in here i can't find it at the moment this is going to be my course course object and i know i had three properties so let's go one two three it was active active is true false name now you can see why templates come in very handy is a string that already was a string i don't know why i bothered to do that and order is an integer i'm still defining the structure just like before when i said the property value was a string now i need to exit edit mode and it's going to ask me what do you want to use for the value of count i want to use the step value what do you want to use for the value of the course list i want to use the step list that's as easy as it is to take those step values and put them into the action values save that now it's time for the fun test how well did we do everything look i've got a filter and i can say let's look for all the ones where active is true now if i go back and look at my courses i can see there are a couple that are not true well one so out of nine records i should get eight back let's run that active is true run the test and i can put other conditions on there as well click it and oh i have a syntax error actually that's good because now we can look at some debugging concepts under the steps you can guess it's only one step so i know where it is and this doesn't really tell me where the syntax error is very well so i often like to go to the system logs and see who had the issue you got to get through a whole bunch of stack trace stuff here but in the log it's going to say somewhere in here uh process automation is a line 22 column 2. let's take a look at that my action pickup record contact that do i have a 22 i am probably missing a parenthesis somewhere i didn't push the object that's my object i'm missing a curly brace which would have stood out if i had done proper alignment anybody in the uh nobody in the chat said hey you're missing curly brace good and i don't feel silly save that test it again active is true run can we use this for generating reports and making them interactive uh interactive reports are totally different this is has to do with a flow with uh business logic as you're processing uh a workflow reports are going to be the outputs of those if you want to know more about interactive reports you can look at interactive dashboards and then you create filters that connect them to those look for adam stout's open office hours on performance and analytics reporting on this same youtube channel so which is there he's got great information and i know interactive reports is over there let's take a look did we get our oh no errors our runtime value is 8 here and my course list is an object i would like to see what that object is but apparently it's not populated something happened why did my why is my mouse not able to i know it's not dying batteries i think it's because my mouse pad is sliding around i've got my outputs here i've got my script list there interesting did i not assign it correctly list.push let's have some fun here let's do a good old-fashioned gs info json.stringify list null four one of my most common debugs that takes this object makes it a printable format in a nice cascading format that i can see click outside the script box to get the save to pop up because i'm done editing now if i hit test active is true run that wait for it to finish go back to my log i should see my output of the gs info and ah default fields is not defined my constant script is dying that was nice i do have a series of these is that a warning it's a warning we can live without a warning but we should probably go fix that anyway let's go back to my script include real fast would it say default something something default fields you know what for a moment let's just comment that out i'm not using it today and i don't like warnings in my logs check your logs periodically make sure you don't have any crazy warnings or errors that you're ignoring just because something looks like it works doesn't mean it's working the way you need it to so if that's working and the log says my gs info object is in fact all the active objects [Music] why does it not return my objects i should have an array of objects down here that i can look at is it because go to the script step again not that one that's my property look up courses cancel that list is going into list yes outputs.list list i'll put the account was working right it's an array of objects with the course in there and the outputs edit outputs did i miss something course list it becomes list active name order this one's got me confused this one's got me confused as to why it's not putting the output list in here let's try that again i hate to rebuild this output but course list is an array of objects anybody's seeing it are we seeing this no just for the sake of argument i'm going to name these all the same that was course this was obj fine we'll do it that way won't let me rename this then if it doesn't let me do that then i'll change it this way course course take that now that's course that's course this is script step list course oops all right stop it just take it from here list to that list and if i edit outputs list course everything looks like it aligns maybe there's something about the naming that i missed that i did implicitly last time let's just run the test i don't need a filter right now run that i still don't have the array object i should have uh like a json description here that i can click and see that's no fun that's just no fun i'm bummed i'm bummed that didn't work so end result would be would be that i could do something like this let's go to my flow and pick that new action from my cls look up courses i didn't put it in a category there's my filter i could choose one or not and when i'm done with that i'm going to get a count and a list and you can see this list is an array of my objects that has a lookup and as i mentioned here's a best practice put an if in here that says if the count is greater than zero so you only run this bit of logic by four each can then start when you do a look up records it also returns a count but for whatever reason works fine in a for each loop when there are no records when you build your own objects like this not so much i just want to see what it's going to say nine times so let's put a log statement in here makes it a little deeper nested i believe this for each thing the development team the the flow designer team was looking at fixing so that it works more like the look up tables but as a safety catch i like to put the if in there now and it'll probably take me a long time before i ever stop doing that let's just take whatever came out of the for each course name since they're all unique and test it course record i really don't care because it's not going to do anything for me in this particular instance i suspect i'm going to get three undefined undefined undefined undefined all right in my execution details it did in fact run this 4-h nine times and okay well for whatever reason it came back fine look up courses still doesn't allow me to display what that object is but i can log it here and as i go through the different keep your eye down here where it says harpo right now as i go through the different records it's listing out the names so i've got the properties for whatever reason i can't see them in the execution details as that json object don't know why i've done it before something mysterious here so we have created a bunch of where'd it go we have created two uh custom flow actions specify your inputs make sure they're human readable specify your outputs make sure they're human readable keep them small and tight so they do specific things if you're returning a list or an array of objects be sure that you're returning a count also so that your flow can determine if it's zero or not and skip over it if it's not zero if it if it is zero why would you want to run a for loop on something that's zero anyway be sure to use the test publish them when they're ready to go use categories effectively lots of lots of things we showed you today to help you build some really good custom actions you'll start to see opportunities for these i had one the first one that i had was i want to increment the value on a field it's three or four lines of script you pass it a number and it comes back with n plus one easy enough and then you could save that in an update record later but it's not there out of the box i wish we had some basic simple mathematic functions or actions available in flow designer so that's going to take care of it today i look forward to talking to you on monday the 27th when i'm going to get into sub flows we'll do a little more work in flow designer around subflow so look forward to talking to you about that and until monday have a great weekend take care be safe be kind and remember if you learn something be sure to share it and you will be helpful with other people as well so roll that music and i'm out of here take care [Music] bye you
Info
Channel: ServiceNow - Now Community
Views: 2,225
Rating: 5 out of 5
Keywords:
Id: R7xR6UVnt6g
Channel Id: undefined
Length: 56min 37sec (3397 seconds)
Published: Thu Jul 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.