NOWCommunity Live Stream - API Adventures - TableUtils

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] well that would be a problem now wouldn't it i've missed the mute button okay no it was not you let's try that again my name is chuck tomasi senior developer evangelist at servicenow we'll figure this thing out thank you everybody for letting me know should be able to hear now [Laughter] better yes thank you sorry about that it's a one-man show over here i push all the buttons and try to keep it straight some mornings are earlier than others i actually said that but you didn't hear me so thank you that's why we have a live chat going thank you for joining this is the show that takes your questions your answers your issues and brings them to life through a short quick discussion today's lesson is going to be about table utils very useful script include that has many different aspects to it and some interesting uh interesting properties that i want to point out we go into i like doing these because it gets us into every corner and crevice of an api so that you become aware of some things you may not be aware of i know i've learned a handful of things just going through this api so sorry about the audio issue at the beginning i will make an annotation in the in the in the description to let other people know to start at about two minutes we'll get on with that let's do the youtube thing again real quick you know right there subscribe share like notifications so yeah i'll hold it up one more time you get one of these on your device so that you get the notification and you know that things are happening wow that hasn't happened in a while but uh apologies for the audio issues we also do this on twitch invite you to go over to the developer community to check out get a free personal developer instance if you haven't already very easy to do sign up say give me an instance you can pick the latest release paris or if you want to practice upgrading from orlando to pairs you can get an orlando instance and do that be all prepared for yourself when you get there we did an upgrade or we did the post upgrade we did the walkthrough of the upgrade center on live coding happy hour yesterday we had a special episode on wednesday because of andrew and brad's schedules so i know a little little out of schedule but it was interesting stuff a lot of good stuff in the upgrade center that's coming in paris i'll be talking to one of our developers on tech now in september about that speaking of techno we'll get to that in just a minute developer portal also has all of your apis we'll be referring to this for the table table utils documentation going through all of that in a minute you can get free learning plans if you were just getting started maybe you just listened to the recent breakpoint podcast yeah this one the uh over at sn excuse me bitly slash sn breakdash point check out the new podcast just launched yesterday really happy with everybody who has gone and downloaded listened either through the community site or subscribed to it on their podcatching client of choice thank you thank you very much i'm very excited and very happy to bring these discussions with servicenow and customers to you so that we can all learn and grow from that it's a whole lot of fun been podcasting for about 15 years and this is like the highlight of my podcast career to be able to talk about servicenow things and have it go so thank you very much let me just scroll ahead make sure i haven't missed anything because this is a bit of a chaotic and crazy start uh invite you to go over to the community at community.servicenow.com if you've got questions yup that's where we get a lot of our questions that's where we get a lot of inspiration if you've got something that's outside of the table utils discussion today this isn't an open live fire let's throw questions in the chat unless of course it's about table utils and you've used it or you've got some experience or you've got some questions about that specific topic please throw them in the chat and i'll try to pick them up as we go but if you've got other questions like rest apis or service portal or reporting community is the place you want to go that's really the best i know some people have asked me questions on linkedin and email and my personal website apologies that's not really the best channel because it's you and me having a private discussion when i may not have the bandwidth to answer tonight i apologize community tens hundreds of thousands of people over there that are willing to help and it becomes a record for people with similar question in the future so way way better one other thing you can find over at the let's bring that up over at the developer side i forgot to mention is uh we've got there's there's the podcast we've got the badge up for the podcast if you missed our tech now on the paris features you can click this badge and say watch now it will bring you right to that article lots of cool stuff watch that little news banner it does change before and after login if you are on connect menu and you go to events you can find out what's coming up in breakpoint i will also be updating the community live stream so you can see what's coming up it's not just meetups anymore we're putting more content in here although we do need a new badge because breakpoint is not a webinar breakpoint is a podcast we're getting a new little badge so you can find out what the upcoming break point episodes are and when they will be dropping so talking about paris with dave slusher on the 19th and wolfgang about now experience components after that so every two weeks on a wednesday we'll have a breakpoint podcast check out the events over there you can see that very very easy uh meetups are also available over there but if you want to sign up or find out if there are other meetups coming in your area or where a local chapter might be and then ping that person and say when are we having a meet up go over to meetup.com like 23 000 other people 23 000 and 10 to be precise have done and get that uh information we do have a phoenix meetup tonight no you don't because they're happening virtually now because of the current situation you can get you know easy for somebody in boston to jump in on a phoenix i know i've jumped in on boston and i'm in phoenix so you can go both ways and other way around and hook up with other people in other areas it's a wonderful thing so i know some people have zoom fatigue this is a great way to get out of zoom fatigue it really is so i invite you to go to the developer meetups uh real quick if you haven't done so already and you if you've built an app or even a component or an integration tell us about it and we'll donate 50 to the un covid19 responsive recovery fund just go over to the bitly link you that you see there i think i already told you about the breakpoint podcast yes i did we do have a tech now coming up on august 18th wolfgang will be joining us to talk about and showing us how to build those now experience components i talked to a customer yesterday that built three of them very useful components that they added to the workspace i was blown away he hasn't touched servicenow he just started on servicenow in april now he's he's got developer experience on other platforms but he just taught himself javascript and taught himself about the now components and got this stuff going i haven't seen the code so i don't know how beautiful or but functionally these things are gorgeous and i'm feeling a little left behind now so i really want to learn from wolfgang what these best practices are and how we interact with the data that kind of thing so join us there go to the link tn78r and you can get sign up for that get a notification put it on your calendar and we'll get you all taken care of for that we will be doing a little bit of javascript today which you can find in the um link right there we'll have a github repo with today's date on it 2020-08-06 all of these code snippets that i'll show you today will be there if you're not comfortable with javascript i invite you go over to the javascript tutorial that you that we have online a series of videos to take you through everything from basic syntax to naming variables to looping constructs and objects and functions and writing through scripted rest api so very very popular thank you everybody who's been sharing that and praising it i i applaud you and uh there's always more share it with your colleagues who are looking to extend their you'll get more familiar so if some of this stuff looks foreign today i have a solution for you go take a look at that in the meantime we already did that screen let's go over to the developer portal and get our documentation so this is our product documentation page this is the developer page i like this one a little bit better because it's got the black background but they are essentially the same page you see how this doesn't really pop i like this this pops so developer.servicenow.com suppose if you get the traditional bell for that and uh i i didn't hear the bell but maybe you did let's go ahead and we'll go through these table utils has a number of methods a number of functions but to use it you need to instantiate it with the new keyword now i do need to warn you that table utils is global scope only so if you're trying to use this in a scoped app there's there is a workaround which i will show in a future episode but for now this is global only very handy utility when working with tables particularly extended tables so think about task and task as it extends to change underscore request and incident and problem and sc underscore task at a whole bunch of other tables also the cmdb structure is all hierarchical with extended tables off of extended tables off of extended tables sometimes six seven layers deep sometimes it's handy to know where you are and who are the children and who are the parents and where's the top and who's everybody in this family and we'll go through some of these there are some uh destructive methods in here that you can see let me get the right pointing device like drop i don't invite you to stick the drop because it drops a table it drops gone destroys it the table and the data i'll show you that in just a second in fact let's start out with that one since we're going alphabetic i have a number of scripts over here on my vs code and it is simple to use you drop a table you put in the table name and it's gone i'm i built some tables here ahead of time just to demonstrate these to you one's called you drop it the i do have to instantiate the table utils i call it tu you could do this in one line by saying new table utils dot drop and then put the parameter in there i'm breaking it out so that i can use it multiple times perhaps in a loop so that's just a syntactical way of doing that oh i should back up well i'll talk about this when i get to the extension part so real simple i take this script and feel a little out of sorts today but we'll get there i have my scripts background let me make that a little bigger for you i had better put this into the global scope actually you know what let's see what happens when we try to run it from the wrong scope if you try this and say run script it will say table utils is not defined oh well okay let me fix that by saying global.table utils i'll just make sure that i identify what scope it is in and it says no you can't do that illegal access to private script include and the reason for that is because if you go into script includes under system definitions and look at table utils it will tell you i am in the global scope and it is available to this application scope only nobody else can use me unless you're in global okay which is to me the absence of all scopes but the point is i can't use it in a scope so if you get a message like this it says illegal access you'll know why let's switch that over to global scope and try running it again in that case i don't need global because it's implicit that it will put the scope on there and it says goodbye table and it's doing a whole bunch of other stuff in here you can see it's updated and inserted a whole bunch of records a whole bunch of tables and it says this table is gone table dropped if i try to go back to my let's bring this out i try to go back to u underscore drop underscore it dot list it's gone totally gone now fortunately i have the rollback recovery checkbox turned on and i can bring it back say oops i really didn't mean to do that and say roll back the script execution yes and get that table back i don't anticipate using this too much you may have tables in dev that you just didn't mean to create and you want to blow them away fine but this isn't used a whole lot and it is very dangerous so please with caution kids don't try this at home all that kind of stuff let's go on to our next method let's back up get the next one the next method is drop and clean well what's the difference ah okay this one drops a table and cleans up references so if i had records that referred to you drop it they would still contain and all i did was the drop method the values in the fields referencing that table from anywhere else think about the user table if i were to drop this user well that would be a bad day and i would eagerly hit that return or roll back button but if i have another table that i drop like hey i've got other records that are referencing you drop it they still contain a sys id if you go back and we look at cascaded delete rules remember a few episodes ago i think it was april may when we did cascading delete rules there's a number of things you can do to the records that are affected by that record being deleted well this is a table being deleted and it's deleting a whole bunch of records uses that same technology to say oh if this record in this table over here is pointing to a you drop it record and i the table's gone this still holds a society it's pointing to nothing what would you like me to do t drop and clean we'll go and clean that up so i have a drop and clean table and it's referenced from you ref drop and clean and there's a field in there let's take a look at the table structure real quick i'm over here i have a table called you drop and clean i wasn't very uh creative in my tables i have three developer instance just random numbers i picked out of a hat there's nothing else in there they just have a name field nothing special but i also have u ref drop and clean this table over here references that other one with a table i missed let's go to my script and see if i can type it better this is when copy and paste comes in handy i lost my you rough drop in clean table let's see if i can find under tables system definition maybe i didn't restore one after an old demo that would be a bad day so name is you ref uref to drop and clean well shame on me okay let's use that to look at the list and it has a reference field in here there's my drop-in clean wreck let's go in here the reason it popped up the drop the other table is because it this is a reference field in column one i tricked myself so reference field to other table pretty straightforward right if i show this it says my table is you rough to drop and clean the field is called drop and clean rec it's a reference to this other table you get the idea just like referencing a user office user nothing special there and if i drop the other table this field will be cleaned out now if i don't use drop and clean let's first try that with just a drop let's go back here and say clean out you drop and clean that gets rid of those t the table and those three records 79 000 79 000 102. do that and it says okay bye your table's gone however if i look at this particular record and before i forget let's open that just so i can get it back later i want that table back i am going to take the table name and rgr equals new glide record of that table gr.get this sysid that's why i copied the entire url because i want that record and that value and say grgs.info gr dot whatever that field was copy field name drop in clean wreck i think it's a you drop in clean wreck u drop and clean wreck it's going to say a ssid if all goes well and it does it says this id to nothing because the table is gone now what drop and clean does is let's bring that table back from the dead summon up whatever deities you want and say oh bring me back table from the dead this is like having a seance or something maybe we should just call that script execution history roll back it says we now have i guess you could call a zombie it's been dead and it's been brought back to life i now have let's make sure that works i have my record back i can go to that record i have my table back great ta-da let's go execute drop and clean on the other hand actually you know what i want that script that is handy because i'm going to pop that into the same record let's go and use drop and clean to show exactly what happens here new table utils drop and clean the drop and clean record their table excuse me run run run run run run run and verify that you drop and clean is gone hooray and also verify that let's go get that other script that says hey now what's in your field nothing okay if i take this table and select the all and get just the draft to drop and clean go to the try that again table i don't even have the field it not only cleaned up the values it deleted the field says there's no point in having a reference to this table if the table is gone so any tables that have a reference will be affected by drop and clean gone there is no record notice that that used to be my first column it said dev 79 000 in here it's not there if i go to configure table is good it only had like one field on it and i configure my table and say tell me what columns do you have there's no more reference field to the drop and clean table so again be aware of the scope of what you want to do when you drop a table this could be very handy you may decide somewhere in your process that this table is no longer necessary and think of the labor it would go to to go through the dictionary and say who's referencing this table and clean up those you can do it all at once gone again very destructive very powerful but it could save you a lot of time if you change your data model in the future which i have which is a pain when you say hey get rid of this so do the destructive part before you do any other reconstruction because you may have actually referenced nevermind okay go on let's continue on with our next one which is i don't think we need this anymore but after drop and clean comes drop table and extensions so i've created a base table and then extended two child tables from that you may want to destroy an entire hierarchy at once a whole family of tables that's what this does now here i've got u-drop base is the top level u-drop ext1 and u-drop ext2 are the subtables kind of like incident and problem are both extended from task don't drop all extensions don't don't notice here i also went with the other syntax where i just did it all in one line just to show it a little difference and if i not that app if i go back to my browser into my here we go one line kill the tables and it will kill all the tables one question will the same thing happen if instead of reference as a document id excellent question i don't know because a document id doesn't reference a specific table it reference it has a table component and and a reference field so it acts the two act as a pair and the reference is the document id field is dependent on the table so don't know i suspect it will remain untouched because it's not a true reference field but good question i will see if i can find that out for you all right i have dropped the table and you can see if you it's interesting to go through some of this stuff and see what's going on removing lists for you drop ext1 related lists it's going through and doing a whole lot of stuff that says where could this possibly live in the system and when i create when you create a table you know you automatically get a list layout and you automatically get a form layout and you automatically get a lot of things well this is going and cleaning all of that stuff up so you don't have these little bits and pieces laying around all over the place so removing form sections removing lists through it does all of the extensions first so you can see here's here's all this stuff on you drop ext2 here's all the ones on ext1 and here's all the stuff on base so it does it from the children on up in reverse recursion order or whatever you want to call that and again i could go and recover all these tables if i wanted but they're gone i think there's one more drop nope that's it that's it for the drops now other thing to note is the way that this is configured in the destructive drop methods the name of the table goes into the method not into the constructor when i say new table utils there's nothing in here that flips for all the rest of these so when i look at get absolute base i have table utils and then the method is empty so pay attention to that there's also something else that goes on interesting here when we start getting into lists of tables that i'll show you in just a moment so get absolute base if i am way down in the cmdb like cmdb underscore ci underscore ip underscore switch okay what is the absolute top of that that i can get so i've got one for incident you would suspect it's going to say task i've got one for cis user well that's not even an extended table on this instance or maybe it is i think i may have done something to make that oops i may have just destroyed my demo because i was working on something monday that uh changed the rules to this demo but there's also no real table instead of cis user let's do uh someone give me another table that is a totally bespoke table let's do actually you drop it there we go that is not extended from anything and i think it still exists does it not i restored it i didn't kill it one last time you drop it dot list okay it's there doesn't extend anything it's not extended from anything so we will have a totally standalone table i am going to i created a list of these tables in an array and for each element in the array i'm going to pass it in and say show me your table name and show me who your absolute base table is let's throw that into scripts background and it says incident comes from task you drop it comes from itself again that's what will happen if it's cmdbcip router comes from cmdbci i would have thought it would have come from cmdb that's an interesting notation there so pay attention and no real table there is no no real table on this obviously it's not a underscore it's not a scoped app it's nothing this table doesn't exist it will return the own name so if the value is something different you know it's an extended table or a child of an extended table uh what about list collector field what about it the i'm the issue you're going to have to clarify what you mean by that question this uh we're not doing anything with list collector fields we're doing things are you talking about a list collector field that may reference a rector like a list field because a list field is very much similar to a reference field it can reference multiple records so i think you're adding on sachin's question about document id so if you've got drop and clean go back up drop in clean goes through and says are you referring to this table are you referring to this table are you referring to this table if not if you are i'm going to get rid of those fields entirely so that would be yeah when you drop and clean a task table with list field yes that good we're on the same wavelength a list field is a reference field think of it that way a reference field holds one society a list field holds a comma separated value string field of societies my gut tells me yes i will verify that one also but it is a reference to that table and if the table is destroyed with drop and clean it will clean up those list fields as well all right that's get absolute bass very handy i've used this before you don't have to use in a loop you could just say hey what's the absolute base of this table i can't recall the exact case where i used it but it was uh very handy next one is get all extensions let's go back here this one is is interesting because it returns a java array and this is part of the reason why it's global only because java objects are not allowed in scoped applications so you will also get a little confused and i'll show you what happens to this i also put a note in here that's not in the documentation this effectively looks down the tree so if i'm on task it will look down to incident and whatever else extends from incident or cmdb is a better one because it's a bigger more hierarchical table it's got more layers to it it looks the base table up at the top it looks down at any tables that are extended from this one and you'll also note something a little bit different when i get to another method so let's take a look at this one we're going to go back to incident cmdbci server sysuser in this case i do want this user and put that in and table not found another fake table i like to throw in crazy data when when testing this i want something that i know has extensions something i know does not have extensions and something i know doesn't exist easy to do same thing go through the loop let's run this and see what we get with this it says incident is not nothing extends incidents so what you get is incident what extends from incident nothing so here's your name back note that it does return the table you asked for so it includes the table you pass cmdbci server includes data power server winserver there's a whole bunch of stuff underneath cmdbci server look at this list it goes on and on and on and on and on all of these things come from cmdbci server in some way shape or form if it's one level two level seven levels down it's all part of cmdb iccs very handy if you've got data that you need to clean up now the other thing to note is the type of answer it gave back notice there is a space in here also notice there is a bracket in here that is a telltale sign from gs info or whatever your output is this is a java array that matters because you cannot do a for loop with the dot length there is no dot length attribute difference between java arrays and javascript arrays is monumental when it comes to trying to use them in a javascript they're not even recognized as javascript arrays they don't work so where i had this statement before like here is a javascript array it looks very similar i've got square brackets i got commas what's the problem chuck well there's not a dot length attribute to a java array you have to use a size method not going to get into that today but it's just it's different and you should recognize that table utils when it returns an array and the documentation will stay say straight up that it returns let's go down to one of these drop and clean drop a clean dot get absolutely get all extensions type array list returns a list of tables it's not in it's not explicit in here what it is but this is this has gotten me into trouble before like it looks like an array gs info says it's an array what's the problem what's the difference between that and let's just copy that and put in another one here j2js there is a little utility that converts it from java to javascript watch the subtle difference no more brackets no more spaces this is a javascript array i can now use a for each and a dot length attribute and treat it just like any other javascript array you want to learn more you go back to that javascript course that i had before okay this is very useful when we we're mapping via api reference fields or use array utils to convert it i think you could yeah there wasn't a method that i covered a few weeks ago on array utils so i i think i even had a question what's the difference between that method and array to ras i think it was what two array or two something that's why i do these videos and read the documentation so i don't have to remember everything at once so very important all of these table utils that return a list of something are java arrays so keep that in mind okay this one looks down let's go back to another one we've got get all extensions get hierarchy get the list of all the tables participating in the hierarchy of the specified table effectively does i get tables to walk up i'll get to get tables in a minute and i get all extensions to look down again note this requires j2js to convert it to a javascript array i am putting all of these scripts with all of the notes into the git repos so if you want to find that bitly slash sn-cls is where you can find all of those let's take this same kind of thing incident cmdbci server sysuser and table not found copy paste run and it says incident the entire hierarchy for incident going up and down is incident task cmdbci server note that it does this in two parts it looks up the table all the way up to cmdb and then it starts looking down same thing i got before with cmdb data power server all that good stuff sys user has a number of them because i was working with the new paris feature for user self registration and it made a whole bunch of tables on me he extended from sysuser so cis self-registered user you self-register there's some importing stuff going on here i forgot it was all in there and i've got a scoped table that is extended from that as well because i was trying to impersonate something that i was doing before if here's here's a side note if you are looking at using the external user self registration in paris i urge you to wait until patch one we've discovered something from customer feedback that is causing us to re-architect this a little bit and if you implemented it today good on you happy that you're an early adopter but you will have to make some changes later so we're chaining this out some of our csm customers have given us some feedback so just hold on i blazed the trail out of curiosity as well and went i think i've got it and then one of our product managers said we're going to be changing that so don't invest too much effort patch one is mid-september-ish i don't have a definite date on that but look for that and then come back and look at it a little stronger so just a word of caution freebie for this one all right table not found again an array of table not found yet notice the square brackets and the spaces these are java arrays we will need to convert them if we want to do something with this information that is get hierarchy looks up then looks down there's also get table extensions let's go to that one next yes we are going to go through all of these this is same as get all table extensions minus the current table this one took me a while i said what's the difference between get table extensions and get all table extensions there is a difference watch what happens i say task cmdbc cluster node remember get all table extensions got task and incident when i passed an incident this one is just ever so slightly different you may want to do something to all of your child tables all your extension tables and not affect the current table this one does that so i pass the insist user notice this user is not in this list that's a little shorter than the other one i passed in cmdbci cluster node cmdbci cluster node is not in here but the unix cluster node is the storage cluster node is and the wind cluster node is and table.found does not include itself it did before so whether you want to include or not seems like it should be the same method just put a flag on there like a true false true include false no i'm not going to get into that today that's that's a architectural design that predates me in servicenow by a long long time but we've got two different methods should have been a parameter in my mind all right next on the table is get tables this is the one that walks up that i mentioned before so we're getting you can get let's see if it also includes the current table so if i walk up from incident does it also include incident this is just kind of fun to play with and the answer is yes yes it does so if we had been naming them differently it would have been get all tables and get tables so get tables shouldn't have i'm not going to confuse the issue but just recognize what is included and what is not when you do this you could easily put into your loop and say hey if this is the same thing i passed in then skip over it in this case you may want to do things to the parent table or at the absolute base or discover which one of these elements is the absolute base table you can start putting these things together in very useful ways i think we have one a couple more couple more has extensions just tell me if it does or not i had cis user in here before i started playing around with the external self-registration and it used to say no no it doesn't okay i believe this returns a boolean so task yes task has extensions we all know that from first grade incident does not it's the end of the tree it's the last node on one of those extended tables nobody extends task why is this useful because you may want to again combine this with other features and say if it has extensions then let's go and get those extensions and do something to them maybe you want to drop them that would be fun wouldn't it if not let's let's terminate right here or as you're doing an operation that says go modify the dictionary attribute on this field and put this field on the form if you watch my uh forms and list data model video a few weeks ago you may i've had this request before somebody said how can i put this field on every form wow i mean extensions and everything that is a monumental task it's doable but you need to understand the data model and you also need to understand the ordering and reordering the numbers and inserting and that could get a little crazy but technically it's possible to say go get all of the extensions i know where it is in cis ui section and the fields insist ui element all of that good stuff put the tables together with the data model element and you can start affecting the ui in that way okay sysuser does have extensions table not found does not so exactly what we would expect from those answers is based class ooh this is fun okay what do you think task is i would think task is a base class incident is not cmdbci maybe it used to be in the old days before cmdb came along so let's see what it says cluster node this is a way of just saying hey are you the parent or not we know how to get the absolute base name but this is just a way of if somebody passes a random table and we want to do something or not we can do it that way what was this is base class oh i have the wrong method in here i have a solo class which is the exact opposite don't wonder why task came out with a false let's fix that up before i ship it off to you errors in production code is base class determines if the table is a i think i have a copy paste issue in here like i did i modified but didn't save is a base class meaning no parents and no extensions no that's not true meaning it is the top of the hierarchy fix that for you as well put that in there task is true incident is false cmdbci is false it is not the base class cmdb is now the base class that's been there for at least five years i don't remember when it showed up i think it was about the time we started doing service mapping cmdbci cluster node no sysuser is a base class it has extensions table not found is not a not a base class so it just am i at the top of a tree or not such as i may have limited thinking but where get hierarchy will be useful uh it gives up it gives up and down the hierarchy in one call which is good but there is no separation between the values i don't know that it necessarily needs to if if you're thinking about it let me let me show you a visual of what some of these look like so if i go to let's go to you let's key cmdb ci hardware dot list show you a neat little trick i could do this through the table definition and look it up there what i'm really looking for is the configure table form in here i'm going to make that just a little bit smaller so we can see what's going on just a wee bit better down on the related link there is a show schema map this is doing some of that same logic where am i in the hierarchy who's my parents who's my children and if you can see the whole thing let's take out referenced tables and referencing tables just to show extended and extending and we can see this looks up the tree from hardware to cmdbci to cmdb this just goes down one level i can right click and say focus on this table cmdbcipdu and it will take me to the next one so similar kind of things i don't necessarily need to know in a script which ones are up and which ones are down and where's the i guess you could if you wanted to i don't know if you wanted to sort these or do whatever uh but you could use the other methods if i were to use get all the whole hierarchy get hierarchy and i've got the looking up part followed by the looking down part i know where that is because i could take each one of those and say are you the base class if you're the base class then i'm done looking up so you could do that it would just take an extra if statement uh if i need to both up and down the tables i need to actually do two calls and get them separately could do it separately as well it's up to you do you want the whole thing do you want partial thing so that is get base class and of course i accidentally showed you solo class which i don't have in here but i will make for you a new one right after i'm done with this but it would be the same script let's take this script my list of test variables test tables put that in there change that to is solo class a solo class is a table that has no extensions and is not extended from anybody you drop it was a good class a good example of this it's just a standalone table these are very common you may use them in your applications for doing data lookups or supporting or reference to something instead of a choice list lots of different uses for a solo class and if i look at these it will say task is not a solo class it has extensions incident is not a solo class it has a base class so both of those fail anything in the cmdbi cmdb is pretty much false cis user is false oddly enough this table not found is true even though it doesn't have an actual table let's also put in our you drop it table just to show that a real table is true so this is a standalone table test all these cases to verify on your own okay glad we could clear that up for you i think there's one more and that is table exists why do you care if a table exists well you may have somebody entering a table name or an import from some other system and you want to know do i have a table like that should i have a table like that do i need to create a table like that should i just should i drop a table like that um just because it's on a choice list doesn't mean it really exists so it's not a bad idea to check if that table exists a couple of real quick examples uh this one again note that any if you're doing one of the drop operations the table is passed in the method this one is set in the table utils not sure why that dichotomy exists but it does i am going to take this and just give you a couple examples i've got one that really exists we all know incident we all know that my table does not exist and away we go i should get a true and a false and i get a true and a false so not a bad idea when in doubt check if a table exists it could in fact stop your code terribly by saying hey none of these things you know you're asking for undefined values from undefined objects you can't do a glide record query the glide record new glide record will fail if you pass it a bad table name anytime that table could be a variable from somewhere else an api a user entry a choice list not a bad idea to verify that the table exists okay i think i'm just going to check over my notes table utils very handy script include to be aware of the methods that are in there for identifying and classifying tables where they are and who's their parent who's your daddy sorry couldn't resist saying that and uh do you have extensions are you stand alone a lot of good stuff in there that i i knew a few of these from experience in the past but i haven't gone through end to end before so i hope you appreciate that keep it in your back pocket you may need it at some point join me next time on community live stream monday august 10th where i'll be covering many too many tables see how this kind of goes together with the table theme i should have done this on a monday wednesday or monday thursday pair but it doesn't work out that way sometimes so many too many tables i'll show you how useful they are how you implement them and even how you change the definitions or because there's some read-only stuff in there that gets really nasty later on hope to see you there after that i'm going to be getting into something fun and teaching you the basics of building service portal widgets which i'm really looking forward to so those of you who want to start building custom widgets this is a nice introduction to that and i will build on to that in later episodes as well maybe not consecutively but they will come in there all right more more content playing out for the month but if you've got questions do like john does do like steve send me an email check out tomasi servicenow.com let me know what's on your mind what you're curious about would you like to explore platform topics only if you asked me to go and look at something in the itom space i'm going to have to decline it's not what this show is about it's not where my expertise is i am a platform integrations custom application guy so that's what you get and if you have additional questions beyond what i can answer please go over to community.servicenow.com ask your questions there a lot of bright people eager to help just chomping at the bit to to get that done for now i'm chuck tomasi and until next time thanks again i hope you learned something you share it and you're helpful till then take care have a good day bye now give me a high five you
Info
Channel: ServiceNow - Now Community
Views: 1,389
Rating: 4.9183674 out of 5
Keywords:
Id: vvmQD_barhc
Channel Id: undefined
Length: 53min 12sec (3192 seconds)
Published: Thu Aug 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.