Flow error handling in San Diego - Live Coding Happy Hour
[Music] hello and welcome to live coding happy hour today on uh february 25th we are happy to be here and talking servicenow development with you uh but before we get into anything specific let's do some introductions and we will start with uh earl hi everyone i am earl gk i am a developer advoca i'm a developer advocate at servicenow i was uh previously with a bunch of universities in california uh and enjoying servicenow about six months ago uh we'll and go to mark that one what's up everybody my name is mark scott i'm the senior platform architect for now learning um and also a big fan of servicenow making servicenow content in my free time so yeah happy to be here yeah before we go past mark yeah you're you're like the senior architect on the whole now learning 2.0 thing that just launched right so yeah that that whole thing that it took like everyone was like what are you doing at servicenow i'm like i'm just i'm just here just kicking it like we're not doing anything took a whole year took a whole year to get out finally you know everything so yeah 2.0 i'm not the only architect obviously there's there's more people that are involved and we've got a great team and really excited that you guys have been really enjoying the new platform so yeah yeah it's awesome so if you like now learning 2.0 give give mark some love in the chat and my name is brad tilton i'm a senior developer advocate with the developer program here at servicenow i've been developing on the platform for a while and i'm excited about today's show but before we get into the specifics of the show we have to introduce our sidekicks uh after weeks of us um me trying to do different beers i kind of got burnt out and so i went back to just a classic jim beam straight whiskey uh this is a bourbon straight bourbon nice yeah that's so much that's let's get into it today um so i uh dug into my stash of uh it's called pumpkin porter it's from four peaks here in arizona um it's a little warm out right now in arizona for a pumpkin beer but that's all right i'm gonna drink it anyway i have a uh founders kbs the original uh imperial stout aged in bourbon barrels so i'm excited about that anytime you can ages out in bourbon barrels i'm on board so that's that's me all right uh so this was flow designer week in the dev program uh we did a show on tuesday um around what do we do flow diagramming and there was another thing um [Music] yeah there was two topics i can't remember what the other one was somebody will be able to tell us so yeah flow diagramming and something else and then the other big flow designer thing is uh is some of the debugging and that's what we're going to get into on today's show uh with uh with mark is going to walk us through some of the debugging uh and yeah mark maybe you can walk us through some of that and then talk about like i know that the now learning 2.0 whole deal used a lot of flow designer maybe a little bit yeah let's i mean let's go there first um we you know drink our own champagne at servicenow right so um integration hub and flow designer definitely are on our big we need to be using this technology uh just like everybody else out there needs to be using their technology so we actually migrated 100 of our uh outbound integrations for now learning to flow designer and integration hub so no no in-line flows no uh i'm sorry no in-line um integrations no uh rest messages defined in the uh in the platform it's all through flow designer and integration hub now nice and um okay so what are we what are we doing today right so uh try catch air handling obviously huge big big part of what we had to do um part of our migration right and and overall kind of the iteration of our code moving forward right need to make sure that we're handling our errors gracefully and what i have um first of all is in the brand new polaris ui this is my employee instance um and it's nice and purple uh but i have again probably one of the more interesting servicenow use cases uh that i could come up with which was uh i'm i'm a big fan of theme parks i love theme parks and i hate waiting in line i felt like servicenow could probably solve this problem for me and what i've done is i've integrated my servicenow instance to a node.js api that actually pulls in current wait times for theme parks around north america and i digest that data and i throw some of that up into a dashboard you can see that here and i even get so far down as to break it down by park um i've got a bunch of different statistics that i'm running out of this but um right now it's just a bear api i didn't put any air handling into this so i'm hoping we can tackle that today so this is uh this is to help you determine like when you want to go to different theme parks when they have low wait times yeah i mean this is awesome this is i mean okay so this this top graph is the one that i'm really looking forward to so not next week but the week after i'm going on vacation and i'm going to disneyland uh i wanted to know what days i should plan my vacation around so what days of the week is the least impactful for the crowds what days of the week is the most impactful and kind of you know on average what's the weight that i'm looking to you know looking what's my pain point going into it right before i uh before i get there so um this is this is kind of what i've been building out and i know do you guys ever have that project that you just kind of bring with you like over and over and over again you write the same code over and over again yeah this is that project for me i've written this a few different times in a few different platforms this is just the latest iteration um yeah this is it's just this weird labor of love i guess you could say so yeah awesome there are a number of disney blogs out there that would love to have your data i know i know i don't want to supply it to anybody yet because i'm it's my own like yeah because the moment you share that out then your data is going to change yeah you've complete you've yeah it's it's what's that that observation effect right the the barbershop yeah or yeah yeah either one right yep so this is a really exclusive live code uh so everybody should be paying attention here this code exists in one instance well it could be backed up somewhere it's it's backed up on my github but it lives in one instance and it's one data set and when we sit here and start implementing all of these errors i'm going to have to go and clean all that data up later so i hope you're happy but um yeah this is it man and it's all through 100 through uh flow designer and integration hub even the digestion of data i did i did actually this was my use case for using remote tables as well uh we can even dive into that a little bit and i can show you where i've been using that but yeah pretty cool um okay so i figure let's start at the start right first of all i've got an api here so this api runs on glitch.com if you guys aren't familiar with glitch.com amazing amazing resource it is an ide slash sort of pseudo host of your code you can just write it in line right here and then it just happens to work right away there's no compiling or recompiling it just happens so i love using glitch.me or glitch.com yeah i think um jace's old discord bot used to run off of glitch yeah and and i think jason's the one that got me into glitch so it's awesome um if you if you haven't had the opportunity to see some node.js here it is right here's some node um it's pretty easy the the the startup here i've got a server.js that's the file that we're in right now and it it just hosts a couple of routes so um this route downloads the entire database just in case i wanted that i don't but in case we do this is the one that we're really really going to look at here it's it's the app.get for rides this actually goes into that database and pulls out all the wait times for each one of the parks and the rides this is the workhorse and this is the one right now where if you see the only thing i'm doing is if there's an error or something i'm just logging it to the console and then just responding with an empty bracket i mean this is this is the developer's like guide to air handling here right write it to the law could just do with something else with it and just keep and just keep going please just keep going yeah just just resume there it happened yeah mark can you zoom your browser in just uh maybe sorry yeah absolutely hi jace there we go yep jace is gonna pick through my code um yeah don't this is bad code guys by the way by the way terrible i this implementation was literally to just extract these rides and get it out and into service now as quickly as possible so there is a bunch of hacky stuff in here and don't don't worry about it we've all done it we've all been there right no no apologizing no apologizing right so um literally i just iterate over the parks and pull all the rides out it's not it's not awesome but what i was thinking we could do is instead of doing the correct thing here is maybe we'll just comment this out oops well we'll just move this down a little bit a couple of lines and we're just going to return an error right so let's just let's just do a let's just throw right here we're going gonna throw some some oh okay so something bad happened the very first time we're actually like purposefully introducing errors in let's code happy hour right like this is this this is the easy part we're just gonna break it so technically if i go slash rides on my app here which i should be able to do if i could see it um oops that was not what i wanted to do i zoomed in and now i don't know where anything is um we should be able to do please hold i click the wrong button while we wait for that we can say um pablo is saying hey i wanted to tune in and say thank you for adding error handling to flow designer it's been so fun and useful playing around with it he's not saying thank you to us is it because we didn't do it oh yeah that's right we're talking about check we are service now we have it yep okay so now i can hit my preview in a new window button instead of you know right i mean it says there's an error i don't know what it's actually doing it's just you errored it too hard i aired it too good i did too good of an error so let's just return immediately so that and this is the awesomeness about this because i have to write the right error into this but this is awesome because you can actually make the changes in real time and it just updates like you don't have to mess around with recompiling or you know running nodemon or something like that i'm gonna cheat here i am not a node.js person by any means so i'm just going to make sure that we're doing this the right way let's just do node.js oh and it should have been through that's what it should do right ah there we go my bad my syntax was a little off it still it doesn't like it that's okay we're going to open postman and make sure that's okay you'd think it would be easier to make this at like not like return something bad it's the first time like on purpose of like no i want to see an error message and it's like nah it's handling it all for us so that's not good that's okay now we can talk about um postman too yeah all the different tools that a developer might use yeah yeah postman it's it's necessary if you're doing any sort of integration postman is awesome right and and especially if you're trying to get apis to to fire real fast this is the way to do it like this is the way to it's it's the cadillac of yeah this um api triggering i actually um i use in my last position uh before i was joined servicenow i used postman to write almost all of my api documentation exclusively really yeah because you can build the the posts and the or the all the calls that you're going to make and then add documentation to each one and then it uh publishes it for you into a nice like form nice uh documentation format that's pretty that's public and hosted by them see i didn't know i didn't know you could do that i didn't i didn't know you could actually make the documentation yourself in postman that's awesome okay so i'm i'm not going to be able to make this error out on my own so we're gonna make it to it because we own the api so the response.json we're just gonna kill all of this for later so we'll delete that we're just going to pull an error in here so in line right all right jordan's saying did you have a return somewhere in there that was killing it yeah i tried it both ways all right um all right and then we're gonna go air code what's that type of error message 500. did that again brad i said that's the best type of error message it was bad bad and i'm bad i feel bad about it i think i think the only one that tops it is when it just says error yeah i like i like if it says uh it was probably your fault oh yeah no it's a pebcak air you know probably exist between chair and keyboard it would be a um it would be a 300 then right right yeah yeah and then now we're gonna get into the subtleties of http error codes but here's something that i do want to kind of show people because this does happen quite a bit and i hate to say that i haven't digested a few apis that do this this is not to spec right my status code is 200. it should be returning an error message it's not right it's still saying everything's fine but if i actually parse the error i'm like oh no there's something bad here right this happens so often yeah i don't i don't like keying off of the status code because half the time the status code's set incorrectly anyway in my in my experience with a great point um what did you know what they said i always tell i teach this all the time to people is an api is only as good as its documentation absolutely absolutely all right so let's now now we're out of node.js let's go back unless it's the servicenow api well no yes servicenow apis are infallible we all know that i've got the right our viewership is suddenly dropping off what is happening it wasn't me i swear we're all fired that's what happened all right so let's go back to more hospitable waters here um so theme parks this is literally i have an app in my in my instance called theme parks and that just makes me so happy um okay so there's only there's really there's not a lot to this right so there's there's two flows um i have one that creates a riot history which we can talk about later but um this is the one that's doing the work here this is called store rides now what does store rides do um every once in a while uh every five minutes in fact it goes out and it touches a subflow called create or update or no i'm sorry repeat every five it creates or updates this yeah get rides so um every five minutes i go through this subflow because i like subflows subflows can be called from anywhere as opposed to a single flow where everything is you know if i need to call it from a code or if i need to call it from a scripted rest api or something else i don't have that option so i always try to put everything into a subflow if i can so i have this awesome subflow that just does this one thing again my favorite being able to click through this ui where it just opens everything in new tabs for me is so awesome let this one load okay and it does it has one action called get rides i know i know i do so finally we're finally to where the work is being done here okay so here's my action it's a single rest step it calls out to my api here slash rides and that get so right now if we call this we're going to get our error message and right now i have no logic for evaluating the error so we're going to have to build this all the way through from the action all the way up through the subflow to the flow that calls it um is is my understanding of this right so the first thing we're going to have to do is add this error condition which i um yeah okay so that is going to be interesting because if my response body contains this json right i don't want to necessarily go with my my parser step because my json is not formatted in that way so i'm going to have to come through through my response body and check to see if it actually contains something okay no no no help from the peanut gallery because i'm trying to so here's what i'm trying to think through right like my json parser step is obviously set up for a completely separate set of data right so it can't it's not going to form it's not going to go to this format right so we need to be act we actually need to be looking at it from the response body so does that mean i need to actually boy it would have been so much easier if my status code would have been too like something other than if it would have been an actual error yeah yeah but we would have been done so quickly i mean i guess i could it's fair come on there's got to be a response message i would expect you to have to add the expectation of a error response inside your json step though as in your json parsing step maybe i'm just going to hit the button and see if it works no you're right okay so there's something important to know what to google kids is saying response.status that's good yeah at the same time hey look at that okay so i mean it's kind of cheating right but that's fine status code pull my pill over here oops that was the wrong one is there there's a is there a um inline function for translating to uh json an inline function like if you hover over condition for the like for the string like that function yeah i don't think so oh boy if there is i'm going to be so happy but i don't think there is no unless i guess the dirt the dirty way to do it here would be to put it pulling the response body and just say contains then like the string of it that's what i was thinking about doing like you could so that is one way of doing it and i have had to do that in the past right but we won't get the error message out of that unfortunately but i mean that's not to say that we couldn't couldn't do that i mean it's just another step that we would have to do um in here right because potentially we could parse the json straight out as an error message as well and just have that as a completely separate string and then or not a string a completely separate object and then from there we could do the check on our 200 status and then plop it out if we wanted to but i don't know which way do we want to go do we want to try to go for completeness or do we want to go for accuracy here uh we're going for get it done well i tell you what we're gonna do we're gonna do it this way first and then and then when we're done we can come back and tear it all up and break it again because that's how it always works um now i've got a question what do you guys tend to do in this situation so with condition one where i say here's the status code it's not 200 it could be anything other than 200 you know is like a is is there a best practice that you would give people at this point like should you say not 200 or should you look for explicitly for each one of the error codes and handle those separately io i mean again the the your your api is only as good as the documentation so it's like if you have if you're the owner of the api and you know exactly what could potentially come out then you could be explicit if you don't know what potentially can come out of this api because you don't own it or they might change it or anything like that then you you probably need to do some catching of um like an out basically like an else like if it's not any of these error codes then you need to do something if it's not 200 still yeah yeah um i'm i'm in complete agreement i like to i'd rather fail open so i'd rather catch everything than not catch something so i tend to do things like this where i go if it's not 200 and even if it's like again if it's an error message that i don't know how to handle i can deal with that later right i could log it and deal with it later as opposed to missing it completely and not knowing that it happened but right yeah we'll see all right i want to bubble this up so uh action um api there question mark we'll try that it's a terrible error message but it's meaningful to me okay now i've learned this one the hard way and i don't know how many other people have got to hit that publish button no we're in a new season we all remember to save and activate it's a new season hey does that mean if i hit the help button that it won't like stick to my screen anymore whoa whoa all right hey i thought errol said it was a new season anyway um that's the second most annoying thing when i'm like you can either publish something and it doesn't publish you're like no i forgot but that's on you that help thing i don't know who to blame for that one all right subflow so now obviously we're gonna have to push this up through our flow right so i have the error happening here now i have to handle the error in my subflow so let's see if an air occurs in your flow the actions you will add here so i don't know what do we what should i do i've got so many weird things that we could do um because i've got such a weird instance um i'm gonna have it send me a telegram message i was gonna say like either create an incident send an email no it's gotta tell me right away connect chat call for this one a text message trillion spoke on there well that would be neat wouldn't it what's it doing there it goes oh tweet to a disney twitter like no no that's terrible that's terrible i don't want to do this that's not good wait times hashtag wait times yeah right there's a couple of accounts that already do that yeah so i was thinking i mean and i i'm not going to say that i haven't been double checking my my numbers against them but yeah um okay we're not i'm gonna not do that because i just realized that i hardcoded a token in there and i don't wanna do that because i didn't think anyone would be watching let's just open a ticket come on and then you should automatically close the ticket so it's just like a record like fire and forget no i'm just i guess you just do log right just log it to the system log yeah you could log it but here's here's been my new thing why i'm still going to have to go like and look at the log at some point right my incidence at least like that's that's in your face like you know like when when something went down like that guy that'll get assigned to you this is my favorite so let's just do a short description in this because i want to be able to write something that i know pearl will get from one star runner the system is down all right because that's what i always think some system system systems yeah you got it now description [Music] we must be like the same age that's how i know you would get it and everyone else is like what are you talking about all right so what should we say um the ride responding okay last thing boring bits but this is the part that everybody's got to do i said to myself right come on yes my wife has an account in my in my employee instance done okay of course of course right okay now so in true uh true it true let's go to happy hour fashion i i don't i'm i guess i'm going to test this like how do you so once once we've done the true false from the air handling sorry the try catching the air handling do we run the test through this like can i actually run this test here and have it like show up we're about to find out yeah you always run the test before before you finish talking that way you don't have to wait for it it does look at that now hey everyone everybody drink my drink we did it kind of oh man okay you broke it that's bad that's an error message we shouldn't be doing that but we're handling it hey it's great when the episode is about breaking things yeah we're really good at that yeah on purpose we did this on purpose look it's right here there's there's logs air caught all right be clear it's always about breaking things it's just this time we're doing it on purpose [Laughter] exactly this is wait a minute like this is the easiest like mickey mouse happy well not mickey mouse but you know this is like the easiest let's code happy hour because we were supposed to break it and then you know like you guys threw me a softball on this one but i i have a feeling we're not done yet because i've got it up to the subflow um i need to pipe it all the way through to the flow i don't know that necessarily that right there was the place that i would want to handle this well no because i guess in my subflow right so if we think about this for just a second the action gets fired the subflow gets fired and then the top level flow obviously gets fired on a on a timer um if i was to make this the most extensible as possible right this is where i would want that incident to be logged right because if i called this from code i'd want it to be logged here if i called it from code if i called it from another flow if i call so i just happen to put it in the right spot now that i'm thinking about it architecturally where i'm like no this makes sense um but for the for for the completed at home why don't we add it to the flow as well so we'll publish this one and this is just just so that everybody understands like the the the way of doing an action to a subflow and then the subfloat like i mean i really thought about you know when when do you use a subflow how often is this going to be reused probably never but i still put it in a subflow um this this kind of that's that's exactly what we did with now learning right so every time we're using an integration every time we're interacting with a flow in subway if it doesn't need a direct trigger we we build a subflow out automatically right then we can figure out what's going to trigger it down the road be it the flow with timing things like that and that's what that's what i've done here so let's so in now learning if i register for a course i'm i'm using a sub flow right at some point if you if you register for a course yes um i mean almost any interaction that you're going to have with now learning right we uh we sync that data back to uh criterion webassessor um so when you go and take your your exams right web assessor actually maintains all of the test taker information right so you're going to go and take a a a certified application developer you can take it on webassessor that transcript right gets pushed back into now learning well sometimes we have to tell web assessor hey they're they're cad right you have to have a csa so you have to have a prerequisite so we push all of your learning all of your micro certs all of that that gets pushed into criterion and back um we also then you know obviously do some data mining on that in other properties right partner portal has a lot of information about what you've taken and how you've gotten certified because that's how you get partner points and and that rolls up into your partner um there's there's i mean there's a litany of integrations that we've had to um i don't want to say the word rewrite it's just re-engineer and re-architect and and rebuild inside a flow designer and it's been i mean um we were joking about it before right like it took a year um rome came along this air handling thing this was not here before we had to re we'd take everything back to the the drawing board and figure out how we were going to do air handling you know about midway through this this is a very very important topic right like air handling and how you're going to manage this where you're going to and again like i said what why are we logging this crap because that's what i told my team why are we logging this right like what's the point in writing it to con into the logs if i still have to go fix it anyway open an incident it's much more actionable it's all these little things that we've learned in over the last year year and a half now of now learning nice that's awesome yeah yeah all right so just for fun let's let's throw the air handler in here let's do something else maybe there's some maybe there's some flow logic so let's just say that um i don't know what the uh the subflow comes back with an error is there we can switch on top of that let's let's just me it's not so maybe this time it's not that we need to maybe we do need to send an email maybe maybe it's one of those situations where maybe not on your app but say you know the api sometimes maybe once every week it will what i'll get one error because of a i hit an api limit or something and so instead uh just log the last record that it has how about what if we did this what if we knew that there's a maintenance window right so okay this happens this context record for getting right i'm trying to oh run start dating end time of course easy come on servicenow you're you're amazing so what if we did or what if it was i don't know after and then yeah we've got it okay sorry go ahead brad no keep going no my brain just went oh yeah i need another data pill for that because i was just going to hard code it but i can't hmm interesting okay so it's got to be relative to another data point that we have for this this pill picker i was going to say we have a really a really old example of something where it would have been nice if we had used some flow designer error handling where we we pull meetup data into one of our instances that shows like when past meetups and future meetups are scheduled and who's registered and a bunch of stuff from meetup.com and uh it it just stopped sinking we know that because we looked at meetup.com there are some future events they're not in the instance anymore so i spent a good amount of time deep diving and couldn't figure out why it wasn't working and and finally kind of ran some background scripts that ran our uh rest integration and got back an error code that said um we are discontinuing rest support as of uh january 31st and uh you have to rebuild your integration with graphql wow um so that was a thing where you know if we had had some some sort of error handling but to be honest if we had had some error handling built into the integration itself maybe we would have found that out but i i didn't build that uh so i won't throw anybody under the bus but if we had flow designer uh you know using that and using some error handling we might have known right away and been able to fix it a little sooner so that's the thing we have to go yeah and i mean i'm looking at this going uh there's a subflow so like i could just build out a subflow that has that condition right a time condition in it or like like what you're saying where it's actually looking for something like is this a different data set than what i'm normally used to right like that's huge and then i mean especially with this stuff right like this this this is flow designer guys like this is this is the this is the bread and butter here because i can write a i mean you want to log it to splunk log it to splunk you want to log it to um you know anything it doesn't matter you know we we joke about an email or a text message i'm like that's probably the worst possible things and those are the ones you can do right out of the box right like we have all of this capability to just plug this in right here and start monitoring all this right away and i i think that's huge i'm i'm super excited by the potential in this and we're we're going through and making sure that all of our flows are set to be air handled properly um now learning moving forward but i mean it's i think everyone's gonna have to do it right it doesn't matter and and to your point brad like when a when a third party offender stops supplying right right the rest just stops happening right we're not gonna do this anymore like how do you know that and how many people you know actually are looking for that and it's not just break i think that's part of a long-term scalability kind of conversation that you have to have with people is how are we going to make sure that if something changes in the long term that we are not reacting to it that we know that it's going to happen i mean writing it into your api response is probably not the best but you know there's there's the you know where we digest these things we've got the air handling you're going to know about it way way way ahead of time yeah i mean but for us it was like it was four weeks before anybody realized something was wrong and you know what was wrong was that our our whole integration that we built doesn't work anymore so we have to do something new so yeah building in some error handling like this you know it's not even um it's not even like having to forward look at um at you know what may happen because i don't think when they built this they were thinking like oh maybe rest won't be supported at some point right rest of course it's going to be supported so it's more of a like you know handle what we can ex what we can't look forward to what we can't expect yeah so that's kind of what this if we would if we had done that with integration of and flow designer with error handling which we couldn't have done it when when it was written but now if you would do that you would have kind of caught this well you you could right there was you could it was it was hard it wasn't it wasn't fun but you you know you had to write conditionals for every little response that came back yeah well i i like this as an overall approach where it's like hey how do you want to handle this and and what do you want to do in each one of these cases and this is this is going to be phenomenal i i think for a lot of people to to be able to just air handle on this global level and by the way you know i want everybody to take this away too you've got this on the action level the sub flow level and the flow levels so there's no reason you know that you can't bubble errors up there's no reason that you can't write actions that have proper air handling in them and allow somebody else to just handle it in the flow down the line right like it's it's here the granularities here the the customization is here i'm i think this is awesome can we um do i mean i know this wasn't like super scheduled but this is let's coding happy hour can we can we can can i show you guys some remote table stuff yes i guess all right all right so can i but this is my this is my remote table pitch like does any can we do a couple of like i'm gonna give a background on remote tables and why they're awesome i love it yes let's talk remote tables at uh 43 minutes in for anyone who's doing timecodes is that what's going oh man 43 minutes in okay good we've been vamping for a little bit um remote tables a remote table is like having a table that doesn't it only exists in memory in your servicenow instance i know a lot of people are going to go well who cares right but when i hear that i go a new tool for me to abuse right it's it's so cool because uh so let me let me just show you a remote table definition real fast remote table definitions are super super awesome they are actually a query that just builds a table for you and the intention the intention is to be able to um what just do this on like a a an integration so let's say that you have a large amount of um oh actually i've got a really great uh use case with todoist but um so i i've been pulling in like todoist stuff i guess you would call it like um todoist is my um it's my task management app okay uh and it's a lot of fun to just kind of mess around with this but what i've what i've been able to do is build a flow that goes out to my to-do list and pulls in all of my tasks and there's some metadata that i'm pulling in here but that's kind of the big thing it's metadata i don't really care about it that much right it can change and it can it can be different and it doesn't really matter so i literally used i used one remote table on this and all this is pulling in is my projects for todoist i did something similar with my uh theme park app too it's just pulling this stuff in and what's neat you can see i just do a for loop here and then you do vtable.adrow and this is how you're adding rows to each one of the virtual tables super slick or remote table i'm sorry not virtual table i don't shouldn't call it virtual too i would like to call it um so let's just i just want to show you guys how quickly this kind of runs because the very first run on this takes it a hot second here's what is really really really neat about this the second run on this it's all cached so it only takes well it whatever it it was when i'm actually doing the queries i can actually show you where i do the queries when you pull that in it's super super fast because it's cached like up to like you can set the the cache and uh the ttl time to live so how long will this cache actually persist this is like for me this is like a playground because i'm like i can build a table like in code i can do whatever i want with this and it's cached so i've been playing with this for like caching mechanisms and and things that need to be pulled down like metadata this looks like a real table inside of everything else this looks like a real table so all my references are there i've got a primary key you might call that a sys id right but i get to control all that and i can make references even to this data even though it exists only in memory i can make a reference field back to this and actually link data back and forth that's completely volatile in my system it might just disappear overnight and change to something else that's okay that's that's what i love about this remote table stuff that's so cool now so in the chat people are talking about like what's the difference between certain things uh how would you describe a view versus a remote table so a view is a co is a is a way of defining different uh i would say pulling in different data sources right so let's say i have table a and table b and i want to see both of that both of those data's coexisted like that's a great use case for a view if you're going to do a join that's you're going to have to do it you've got to do a view and service now um why this is different is because this is code that's pulling this together so it's not a join it's not a there's no constraints right so i can i can put conditionals in there ifs switch statements whatever i want and and as long as i just output that row at the very end it's it's done now it's not um i'm going to use a big word it's not like polymorphic right i can't change whoa yeah i know it's a 10 word um once the table has been defined with the fields that's the data that's the data set that i have to work with i can't change i can't be like oh i'm just going to add a new field it's just going to pop up over here it's not how this works um so with like a view if i'm joining tables and i do like a an ambiguous join it might just pop up over there this i'd have to rebuild my entire like that it's a table definition so it is defined as a table okay yeah because i was thinking about it in just in the sense of permanency of and what's happening in the background like i think i i think about it as a view is building off of like database sql queries so it's building it all the time based off of existing tables like you said for sources yeah remote tables aren't any of that it's just it's just almost like a facade of a table um but that you could still act on it's not actually existing anywhere exactly if you want if you want like the like every time this table exists right it runs my query that's that's the thing and and okay that's a great way to put it yeah so every time this table comes into existence my query gets run so there's two well unless it's cached right so there's two there's a trade-off here right one if i have cash data that doesn't change like metadata a lot awesome this is a perfect use case for this because you just fill this damn table up and let it go right and and it just changes and does whatever it needs to do and what's neat about this is i don't have to manage the uh the the data life cycle right so there's no deletes on this table i don't i don't drop it right i just rerun the query and it just pops back into existence so that's what's that's what's kind of neat it's a little bit more it's it's a little bit more flexible i would say than a view whereas i'd have to you know do a physical insert to your point right with the rds right like i've gotta i've gotta do an insert on that this doesn't require that i could query an api i could query three apis if i wanted um technically and i'm not advocating this whatsoever but it is one of those fever dreams that i've had about this this i mean you could couldn't you cache this right like i could write a view of two tables and then cache it and it's a remote table right like i don't know i've i've thought there's you know this thing's rife with abuse like there's some cool cool functionality we could do here um but i just kind of wanted to show that off to people and let them know it exists go go find it it's been a lot of fun um messing with this thing you do learn a lot about how the underlying table structure works in servicenow let me tell you you cannot report on a remote table it doesn't it don't not not so hot um there's some you know obviously it's running some queries and doing some caching on the reporting side so if it's gotta run this over and over again it doesn't work so great there's limitations with everything so at that point if you're trying to do anything more than just accessing data from that api or something then you probably probably should just store it and make a table or something in a real table yeah yeah and and you're gonna know and and so the way the reason i bring this up with todoist and you know we're talking about api integrations is this was awesome for my metadata i tried to do the same thing with the ride data and the wait times it it just wasn't awesome like it just wasn't it didn't work the way i thought it would it was kind of a little funky like for example a business rule right like on change business rule when when does that fire right like i i have no idea like in a remote table that i'm defining the query how do i say that data changed right like it's it makes you kind of think a little differently so yeah it's it's it's been a fun little fun little uh interesting rabbit hole to get into i haven't used it anywhere in now learning if if anybody wants to ask that question i have not i haven't found a use case for it yet and that's because there is a thousand row limitation to this which i would want because i don't want to eat up all of the in memory you you know i don't want to dump the the heap in my uh service now inside oh so what mark is saying is once you hit a thousand records just um paginate to a different remote table got it yeah just it's just table name underscore two now you got it yeah yeah i worked in an environment that's how they fragmented like that that's how they did their indexing on a table oh they just broke they made more tables they made more tables because it was oh no it's super inefficient it's got like a million rows in it it's like make another table oh no don't do that oh and now imagine if they needed a cycle of tables too yeah we're like okay archive that kind of stuff yeah well thankfully thankfully they handed it i this was before my servicenow career they handed it to me and said you fix it now so yeah that's fun yeah that's this this is all i got guys i i'm i'm i'm running out of gas here this is great no i think it's good yeah awesome here here come our faces here come our faces there's no easy way for me to warn people about that when i put people's faces back i like the warning normally earl doesn't give me a warning he just puts my face up just shows him yeah usually i it's an ongoing joke right i'm prepared for this i knew it was gonna happen no brad honestly even you don't know how many times i don't put faces on because i'm like oh brad's head is down can't put our faces up right now that's fair as much as i uh like to flash your face in front of the screen um you know watch out for you too i had i had um i just i got a haircut if i mean um and i shaved it and i went oh man like what like i'm not brad enough now like two inches off and i'm like man like hashtag not brad enough let's make it go yeah let's do it let's make a trend they're not brad enough now yeah making another thing hashtag not bad enough not brad enough all right well thanks mark that was uh that was great it was a great uh example of how to use a try uh try catch block and lots of other flow designer stuff and i love all of the now learning like internal bits it's now learning is such a good example like for all of us because it's a thing that i think probably every servicenow developer accesses and uh you know a a good example of like something that's built totally on servicenow it's all using flow designer it's such a cool thing so yeah thanks i appreciate that yeah i i mean we take a lot of pride in that because i used to uh i used to point at other servicenow properties you know that had awesome user experiences and now i get to look at you know point it now learning like that's that's that's what we can do on the platform man like that don't let anybody tell you you can't do it because it's right there yeah i'll be honest like the first time i use the now learning 2.0 and i searched something and i saw the search results i like laughed out loud because there were so many options to filter the search results i was like this is incredible like i can do i can find whatever i want with the filters on the search results this is great yeah no it's uh uh that's been i mean people are like thank you for search like search works down we're uh believe me uh we're gonna continue to put effort into that because even to this day i mean we still use it just like you said brad right like internally we use now learning right yeah and externally we use now learning so we're still using it we're still finding better ways to make it you know we're still finding ways to make it better um search is definitely one of those where i'm like still not and it's not good enough yet like i want it to be super sharp and super clean and and i know everybody's working on it so yeah it's gonna be fun that's great awesome earl how was your bourbon it was solid um uh i was drinking it so that i could loosen up and start um being more sillier so it ended up working so i would probably give it a solid four nice mark how about you uh i mean this is this is always my limited october release and uh so it's one of my favorites it's definitely good good luck finding it though yeah you got to give it a number though oh yes all right um i'm gonna give this one 3.5 all right this is my kbs barrel edged imperial stout it was it was really good i'm going to give it a 4.5 which is pretty high for me wow yeah all right we still have not had a fan of the show come across and to bring us the data and said hey i've compiled all the ratings i would love to know what i have rated every beer but it's going to require someone watching i don't know 50 episodes and telling me or maybe 70 i don't know and there's a non-zero amount of times where we've accidentally ended the show without reviewing the beer probably it is absolutely non-zero you're right uh all right well thank you mark uh thank you thank everybody for joining and this has been another episode of live coding happy hour on uh flow designer uh in san diego uh i would reach out to touch the san diego but earl's gonna have to touch the san diego the other way i was trying to poke your finger oh i drink too much bourbon this has been the third san diego live coating happy hour and thanks everybody for joining us it's been great oh sandy there you go yeah next week we got integration hub coming so tune in for that yeah all right thanks everybody earl's gonna hit the button while he's making motions cheers [Music] you
https://www.youtube.com/watch?v=E_nfeeau810