logo

NJP

NOWCommunity Live Stream - Topical Deep Dive - Form and list data model

Import · Jul 09, 2020 · video

and checklist all right if we couldn't do that let's stop [Music] good morning good afternoon good evening wherever you are and whenever you are welcome to the community live stream my name is Chuck Tomasi from service now been here for over ten years senior developer evangelist and happy to be here bringing you this information we're gonna check see if the stream is up yeah people got it alright thank you very much for confirming that this is July 9th I have to think my brain wants to go very far ahead good morning to everybody who's checking in on YouTube I'll get to that in just a second though July 9th 2020 our topic today is the form and list data model so this is a user contributed question thank you very much John for that I'll get into the topic in a little bit first let's go through the pre-roll if you're watching this on youtube don't forget to share like subscribe hit the notifications you get all that so that you get the notifications when this comes up thank you very much for everybody's checking in druvan Scott and Andre wonderful to see you all today we also do this on Twitch just in case there's a glitch on YouTube you got that for a couple of weeks YouTube sticks around in perpetuity and twitch is for a couple of weeks because it's the free account I don't know why we're not paying but we'll get into that later I encourage you to go over to the developer portal at developer.samsung.com for Paris release that's coming out very very soon later this month we will have that and then when you're done with that you quickly run over and sign up before the tech now on the 28th where Jeremy and Craig and I will be talking all about api's and enhancements and new features that are coming out in the Paris released so that you know what you're getting from your release let's go back to that one of the other things you can do is join one of the meetups over at meetup comm get out of the way so you can see that URL if you haven't been there tens of thousands of people around the globe I participated in one in Pittsburgh just last night and it was a lot of fun smaller group we talked about what they saw did and experienced at knowledge 20/20 got some feedback on that the vs code extension and source control and lots of other topics for about an hour it was a nice virtual Meetup of course all the meetups right now are virtual until we get back to some sense of normalcy and we can do in real life meetups again so good morning to Raul everybody glad to see you thanks for joining Wow good turnout today let's continue on with this this is the ServiceNow community you can see that behind me this is where I get a lot of my ideas letting the inspiration thank you for all your contributions if you've got questions or issues please don't post them in the live chat because I'm probably not going to a not see them because I'll be talking and demoing and whatnot but also they will be short-lived they'll be hard to find in the community it's a record it's there it's searchable people years from now can thrive on your questions and answer so if you're new to the community browse around get familiar with what forums there are it's a wonderful resource this is and I'm not the only one to say this this is the best online community that I've participated in over thirty five years I mean I go back to the old bulletin board days with dial-up modems that's that was one of the early communities that I was on and obviously we've come a long way since then but this it professionally or personally this is the best one that I've ever been on it I don't say that with a bias I say that honestly that is what's what's going on what is the link for Paris well the documentation will be available as soon as early access is available it's currently scheduled for July 23rd so if you go to Docs but not before okay let's go with that I just happened to glance down and see a quick question anything else we're not gonna be doing any JavaScript today so I don't need that link we're not gonna put it in the github so we don't need that link we already did the webinar so let's get on with today's topic and it is contributed by viewer John John is on today thank you very much and we will get started with his question was is there a way for a client script to recognize what fields are on a forum short answer is yes need to be a little familiar with the data model the tables that it takes to put together a form when you do configure form or form layout you're simply manipulating records in a table pretty much everything you do but ServiceNow is in a record in a table somewhere hey it's it's crazy how many tables there are if you've ever looked I think a baseline system has something like 2,000 when I started was around a thousand two thousand tables that's a lot of stuff so when you say bring up this list I mean I can just go to you know this list of approvals it interrogate sat able to say what table did you want to go to what view are you looking at what fields should I put on there is this personalized is it system default there's a whole bunch of questions that happen on the back end platform to present this list that you see here and of course when you drill into a record it does the similar kind of thing what view what table what form what lots of different things go into what it takes to do this now you've seen some of this when you do as I mentioned view for ask you configure form design this is interrogating the same tables just presenting it a nice drag-and-drop UI or if you go to form layout we've got different field types we could put on there these are sections these gray bars are denoting sections of the form if you do form layout configure for and layout it brings up a little different interface but it's doing the same thing you're saying I want these reordered I want these on with these off I'm going to create a new section that's pretty straightforward stuff let me go to my CLS app so that I don't mess with anything too significant how to progress into ServiceNow developer role any suggestions books start at developer.samsung.com there's the short answer give you a thing for that one Bing developer dot ServiceNow com free learning plans getting yourself a personal developer instance good stuff Joe there they are and and I know people in the chat are going to be answering chat questions as well this is a very common question we get might even want look on the community it's been posted there as well so ok back to the topic at hand try not to get interrupted in sidebar too much there's a few tables we need to know about and I am going to bring up my notes so that I don't miss anything because there's a lot of details in here and get this going ok first a caveat this is going to cover all the major points of form and list layout it's not designed to be comprehensive so these are the common ones that will aid you in learning what's in the system how does it work what is it doing to get you through probably 90 to 95 percent of what you need to know if you want to go exploring deeper be my guest I as I was putting these notes together I discovered a few fields and what is that for how does that work and uncovered a few secrets that I didn't know before so I got you from about 75 percent to 95 percent which i think is pretty darn good so let's start with the first one that most people are familiar with and that is a view if when you look at a form let's let's take incident for example incident doubtless very common thing we'll go to global so we can take a look at this in an editable format and you look at the top of the list right here okay up here in the corner it says incidents there's no view name but in this hamburger menu you can select a different view it means there are different layouts for this list if I say portal view this is how things will look on service portal you're going to have fewer columns because typically would be on a mobile interface or something that doesn't need all those details it would just be cluttered there's also a mobile view there's and you can see it says mobile view right up here in the corner next to we if you with the table to say which view you have selected the default view has no name so if you don't see a view you're you're on the default view oh boy not something interesting about the default view in just a second alright so lists have views that means it's a different lens that you're looking at I'm not showing you all the fields on all the tables or it would look like a spreadsheet it would just be a lot of horizontal scrolling and nobody wants that so what does it take to build that well that comes out of a table called sis let me get back up here for you sis UI view and if I put that list on here it will show me all of the views in the sis UI and you'll notice there's only one called default view has no label there's one called accept there's activity and if you look in here there's probably one called self service and so on and so forth this is not that I wouldn't call this the top of the hierarchy it's referenced by lists and forms so it will it will guide you and determine where you need to go or if you have a view or if you need a view by that name so just as a reference it's like real common it doesn't define a whole lot if you look at the default view it's got a name no it doesn't it's got a title it's whether or not it's hidden you got roles that you could apply to that just it doesn't really say a lot the power is in the related list down below how many forms are using the default view a lot okay because every form and every list has a default view every how many sections and we'll get into sections in just a minute it's used like you see here by forms form sections lists and related lists have used separate from the lists I'll get in a related list got it here I keep saying them for referencing I apologize for that if a view there's a couple of things that I want to point out if a view starts with the name RPT it is a ListView for a report these are easy to spot so when you create a report you say I want to change these columns around you're not giving it a view name it's using the sis ID of the report and prefixing with our PT this is the way the system understands this is a report list view that's all it's doing and if you go into that record it will say these are hey look I got one list it's for this change request report you can find out what tables and all that good stuff is in there so that's kind of what views are for they're really a framework for how to layout the columns in a list or define more details about a form did I miss anything the view reference list oh yes yes yes there is a view called reference list I'm just going to I can't type that today reference list there's only one it's called sis ref list some of you may know about this very special one there are a few special ones in here actually I should probably point those out and it is used for listener related lists you most commonly see it on a reference field so people ask me from time to time hey I'm looking at let's see I've got a reference field somewhere in here let's go back to incident real quick did you do incidents and open up this and here's a reference field and if I open up this pop up window with the magnifying glass this is the SIS ref list view so if you want to personalize or configure the you can't personalize it cuz there's no cog if you want to configure the columns that are in here and I often do because I'll pull this up and it'll say like just a name or date go that's no good you can configure this the same way you configure other lists with this menu configure list layout and it will configure the list layout called sis ref list so you can see up here hard to see a little bit sis parm view says parameter score view raph list is the name of that view if you're ever in doubt about what view you've got check the URL probably says sis parm underscore view somewhere in there okay so you could separate the way that your reference list looks from your related list looks from your default list okay special one there if you take a table like task and you extend it to another table like safety or loner request or customer complaint or whatever it is you you extend that task table and you don't have a view for that even a default for you let's do that real quick let's go to tables and I'm going to let's jump back to my CLS app I can do this from studio even easier let's go to studio and create a quick table show you what happens you've probably seen this but those of you who haven't let's create a new table and I will call this Oh view test we'll call that view test terrible name it extends the task table and I don't need a module and I don't let's put it in the CLS menu create that table I get my 66 or 67 default fields whatever that is and let's go back and refresh this so that under the CLS app I now see my view test if it doesn't I haven't defined any form layout any list layout or anything else like that what do you get for a list layout you get the default from tasks this is inherited this is well part of the the task inheritance thing you get business rules you get client scripts to get fields you get permissions you get views so and what I find often times is tasks type is the first thing to go if I'm looking at a list of all one type of tasks through this module I don't need a task type field so get rid of it gone then you can start putting in your other fields that you do need okay you do that of course through configure list layout no no same kind of thing for the forum if it doesn't have a view defined you're going to get the table you extended it from you'll get that view so an important thing to note ago where did this come from and why does it not look like what I need for my process you haven't to find anything yet okay it's inheriting it there is no view related to this table and the way that it does that which is a great lead-in actually before I get into the forms before I get in form let's go back to lists for a quick sec lists are defined in the table let's get up here again sis you probably guessed this one sis UI list dot lists bring that back notice goes to where the focus is now sis UI list is pretty simple it takes a table name and relates it to a view and there's some other stuff in here that I'll point out along the way for example if I look for tables to start with X underscore blah blah blah I have my view X underscore CLS employee with the scope name in there open up that list record and it says this is the table name pretty obvious we need to know what table we're going to list this is the default view but the default view doesn't say which fields go on there it's just a relation to say you have a default view here are the rules you need to see that view that kind of thing you saw that in the sis UI view record some other fields I'll get into in just a second but the list elements this is a related table called list sis UI list element has the fields and the order and any of those field controls remember when we were on the incident list some of you may have done this in the past or maybe not so let's go back to the list of incidents incidents if you take say a numeric field or something of that nature you can do configure list calculations and some of the list calculations you can do our total min Max and average okay that is what's in this record on the list elements which columns do we want a total Mac min max average that's where that's stored if you ever wondered and you have to turn it off and you can't find it you can go to Sicily UI lists look at the related list elements for that and manipulate them that way I do this all the time I want to know what the YouTube views are so I'll take an average and a sum and put that on the views column so I know how many what the view count is for the videos over the quarter over the average it's a cheap reporting mechanism is what it is so you might be able to kill a few reports requests that people say can you make a table that sums this up like you know okay you can actually I can yes let me do that it'll take six weeks and we linked no won't take six weeks it'll take six seconds all right so that's sis UI list and sis UI element let me make sure I did not forget anything in reference to sis UI view we talked about relationships okay there's this relationship field and I wonder what is this and I said what does it do so what kind of label show it and it points to sis relationship there's some other reverse engineering that I did this relationship you don't know is defined relationships so normally when you create a reference field you get a three related list connection you could automatically put a record relating to another table on that tables related list okay that's a freebie but if you don't if you need to somehow connect these and they're not related by a reference field you can do a quick script to relate those one classic example is on the incident table on the incident form you can put a related list of what well it's gonna be what a calls by sorry I had a mental block there it's still early in the morning calls by incidents by same caller okay that's one way you could do that on a list however this one took a little more investigating what is the relationship between a list and a list hmm well let's go and take a look I believe it's on my course table go back to the history go back to this UI list and find my oops already headed there starting with X I think it was on the course table there's one with a parent I'm sorry relationship I think relationship is always empty on list but let's do oops not show matching I wanted to filter out take that out click click filter out and well that's just the ones that I made anything that's got a relationship so sis choice has a relationship of choices interesting that's probably because it might be a related list we'll find out or what it relates to I've got to figure that one out this is it in my notes did I already figure this out once a relationship it eats a my answer is for the scripts but that's not right maybe it is well look get you I'll get back to you on what the relationship is the parent is even crazier what's a parent list for a list I thought that was the related list it is not if I look at my again my tables that start with X underscore I have that relationship empty the to do table okay and I look at two dues in my CLS app let's just take a quick look at that table I'm not going to type that out it's going to be introduced a parent list relationship is when you have an embedded list and an embedded list looks like it's on the videos sorry on the videos records it says my parent is that here is a related list and if I go to configure or layout and turn that into an embedded list you see I've got lists down here to do to video put that in it becomes not a related list it's kind of subtle because I only have one list on here but it's actually part of the form much like when you create a table as we get in studio over here you have this embedded list of table columns you can make changes all day to that but as long until you save they're not saved it's part of the form a related list you're manipulating the records kind of live you don't have to save them so that's the parent field as far as lists are controlled one point something else out that's kind of interesting if you haven't seen this go back to sis UI view for a second most of you are familiar with societies they're a unique identifier in the system that tells it gives a record and identifier when you're referring to a record in a reference field for example or any record in the system it's going to have a sis ID or a gooood as many systems call it one unique thing that I discovered is the sis ID for the default view watch this is one of my favorite little trivia questions what does the Society of the default view we're got vs code so you can see this well look I still have all my things from last time and I hey create a new file the sis ID is default view so if you have some code up there that is checking for 32 character hex values and it encounters this it will fail so just a bit of trivia if there's one other record somebody pointed out to me that I don't remember what it was but it also has a very non-standard Society so you can also see this if you just hover over the record down on the URL on the bottom is in fact sis ID equals default space view if someone had fun with that one just a little bit of trivia that I threw in there for you if a ListView doesn't exist I just created that CLS you of course it will inherit that but if it doesn't exist let's say I went and created a brand new table okay and I create a table called actually let's take one that I've already got let's take my task table take that table go over to my views and see if I have a sis you I often when I'm doing this debugging on lists and forums I don't start at sis UI view because you'd have to go to the related list then you find your filter and it's gonna tell you which list or section or whatever it's in I usually start at sis UI section for forms and sis UI lists for lists because I already know what the table is and I don't have to search very hard to find that if this didn't exist currently it says my task table is going to have active assigned to course description State and I went and configured it and said no I'd rather have assigned to the problem is it's currently alphabetic and I don't want to do that I want this to be it won't display what I want to display zero and this will be for let's reverse these okay so when I look at the task list in my CLS table don't think that was the one state assigned to course description active something happens I don't know what or some administrator comes along doesn't recognize what they're doing and they take this list record and they somehow delete it he goes you know what I'm going to also take out your elements what do you get when you go back to that list because it would be really bad if the system just went oh I don't have anything for you let's not found that that's not a good experience so what happens is if you go back to the test it will build one for you and it says I don't know what you want but I'm going to take a number of fields I don't know if it's all the fields or certain number of them first seven or eight I forget what the logic there because I only have five on this one puts them in alphabetic order so if you see this in your system one of two things has happened something something happened to delete the view the the Ciccio I list entry or it's it's already been created by default now did it actually create a record let's find out lists no no no yes and it saved those so at least I have a starting point and the next time the system references it's not like pulling this all for memory it goes oh yeah there it is okay there's a couple other things that I want to point out there's also a user fielding here in the lists you could probably guess what this is if I have a default view for this then user is empty that's the system default it applies to all users so when I say configure list layout I'm manipulating the fields on this record let's do that oops I'm actually on the list lists we want to be on the task list configure list layout and say let's put state second and description first that means active comes at the end da-da-da-da-da that's the default everybody gets it and we all remember our system foundations fundamentals training the COG icon lets people personalize their list so when somebody calls and says I don't see that field on my list chances are they probably went in here and forgot how they got there and you can always revert back to default when you do this and make a change let's say I really like having the created date out here or as I often do I put the updated data on a lot of Records so I can start them and see what I've modified recently hey this is a very common layout for me is to have a list of Records sorted by descending updated time okay what did that just do that just went over here and made an entry for me this is an override it says hey Chuck's got his own way of looking at this thing so forget what the system says he's got his own special layout so you may see a large large number of these all with the same view for different users okay that's perfectly fine and again if somebody says hey I can't see this you don't want to walk them through the process of go to the cog click set back to standard default or whatever that big button says now you can go here delete their record when refresh and do it again nice to know a little bit about the form and list data model so you can walk around and do these backend things don't do this willy-nilly especially on the system level stuff did I miss anything let's go on we talked about sis UI list element of course now that I've got my own personalized form layout it is exactly what you would expect here are the columns I want and what order and did I put any now users can't do the calculation stuff that's all done through form control so that is what it is it's still going to be the same records with the same list layout this UI related list you can probably guess what that is is the one that shows up over here sis UI related lists skinny underscore list dot list blow that up so you can see it a little bit better so sis you i underscore related to this list is the table that gets you back out zoom the layouts for related lists as I mentioned if you have a list of go back to incident list bring up an incident because it's got a couple of related lists in here tasks SLA is for example this related list layout this comes from the table tasks underscore SLA and this one let's just take a quick mental note SLA definition type target stage business time left blah blah blah if I look at tasks under SLA it may not match it may but it may not match nope tasks SLA type target stage business actually does match you go well where did the tasks field go on a related list it doesn't show the parent record that it's related to so let's go back to that incident real quick um and I have the list layout if I say configure list layout this is going into the cyst recurrence a there's tasks why doesn't task show up on the list is is because you don't have two related lists are smart enough to say of course it's going to be related to this particular task what would be the purpose why wouldn't why would anyone want to see incident 10,000 112 10,000 112 10,000 112 throughout that is a waste of a column so I'm not even going to bother you with that putting that on the list you can define it actually it's coming from the default sis UI list record because there's nothing to override it in sis sis sis related lists hey so the entry in sis related list is really just a binding between the view and the table it it has related list entries in here if the related list entry doesn't exist it takes it from sis UI list it says let's go and do that because I think I just did that in another form or we'll go back to global now let's stick with my CL SL because I like messing around that since the scope is already taken I have my courses and courses have tasks and tasks as an embedded list so let's make it back to a related list by taking form layout removing us from tasks and away it goes it's back to being a related list because it you can't have both or you can't have an embedded list and a related list the embedded list will override the related list and if I look at tasks I have description state assigned to active is that the same as this description state assigned to course don't need it active and this is personalized updated so let's go back to column defaults I don't need course in that related list be cause it I'm already looking at the course why do you you don't need that that's the same thing as I just did with incident so let's do a forum layout on our list layout on this sis UI related list should get a new update let's rearrange the description and the state up up down down and go back to related lists we've got updated course did it actually got created because it didn't exist before so there is course and it says your default course view is tied to this table the related list entries this is the interesting part is open up this record and it says you have one related list because if you have multiple related lists it needs to know what order those going notice the position field here you could say yeah I've got 17 related lists this is where it defines what order those go in so the real value of sis UI related list is not the list layout that goes into sis UI lists it's the order in which those go frankly we probably could have put this order on a different place I'm not sure exactly why it needed to go here it didn't feel like the right place for me but I didn't do the architecture and it still holds up well and we're obviously not suffering any performance problems so that's the whole point of sis UI related list assist UI related list entry let's get to forms we've already covered a lot of this stuff that that you need to know for the basic forms and this gets to the heart of John's question so if I can wrap this up in the next 15 minutes I mentioned that I usually start with this table let's go up here zoom in for you sis spell it right no no don't hit command s sis UI section dot list okay that is very similar to sis UI list it finds a view to a table so again if I look at my tables that start with X underscore something something so thing I'm going to go into the employee table and notice that I have I'm gonna do a show matching on this guy I have these sections these are the sections of the form very easy to figure out it's these compiled together will make up your form layout so this is a good starting point table table table table if I look at that form I should see a detail section an activity section and a stat section and sure enough employee employee on CLS brings up detailed stats activity the one without a caption and there's an order on this is this top part I call that section zero because you'll see this real quick there's an order on these things as well just like the related lists it says where would you like to put this form sections has a sis UI form section so it's not sis UI section it's this UI form section table is where it defines the order this is the part that feels like it should really go up here like why because I've haven't seen too many sections that have more than one sis UI form section entry but a one-to-one relationship pretty much says the field would be better off on that form if I look let me dig in a little further I kind of skipped ahead the SIS UI section element table is where it defines just like the list element table this is the section element table for the forms the order and you can see there's also this type this is where you're going to see things like macros lists if it doesn't have an entry is a straight up filled in at your reference field date field do you name it it's in there okay the splits and the end splits will more than likely be set up this way so you'll you'll see those whether you did this through form designer or form layout you will get this same kind of table structure this is where your fields are so he says hey I don't see a field and you really want to verify that field is on there and it's not hidden by role or UI policy or something else you can come in here invalidate is that field really on the form in that section somebody asked me one time what's the easiest way to delete a form section form designer you click X and it's gone okay it's don't don't come in here and start looking for records and deleting as the position is at the top don't delete that please don't it it's caused me more grief in the past than I could count you have to literally come in here make a new record put some fields on there I just got an error from YouTube oh oh hopefully you're still watching me we wrote to press on as if nothing happened and I'll take a look at it if if it fails miserably I'll upload the recording I've got a local mp4 as well so that actually takes me pretty much to the end we'll see how it goes don't delete the baseline views leave views like default view leave portal self-service if you create a view called ESS it will automatically labeled it a self-service and this is what will be used for users or don't have roles that kind of thing great stuff there's a lot of them that come out of the box don't delete them you can you can create and delete all your own views if you want generally you don't edit this stuff somebody asked me one time is there way to add a field to every form in the CMDB structure because they were they had a new field at the top CMDB CI and they wanted to add it to every form I said you're gonna need to know what section it goes on then you're gonna have to create a section element record and you're gonna have to make sure that there's nothing in that position it gets really convoluted but you can see how knowing the table structure of lists and forms can really help you do something like that that was a one-off in John's case is question of how do I know what fields are on a form you're going to sis UI section you interrogate the SIS you I view URI parameter and say get this table get this view go get all the sections and you could put together a server-side script that builds an object an array of objects and says here here an array of fields and types and whatever else you want to put in there and their positions you can go through sis UI section you can go through sis UI section element build this object in a display business rule pass that to the client script and the client script now knows what fields are on every form so not too difficult but nice to know what did I say it say it again don't delete section 0 from sis UI section and if you must make changes directly to these tables make a backup first export the appropriate tables to XML sis UI sections Sui a section element sis UI views this UI list sis UI list element take those and back those up just like any good developer would do make a backup before you start experimenting even in dev it will it will really pay off so yeah I notice we're getting some pauses I'm gonna check bandwidth maybe it's an issue again that takes care of it for today thank you very much for joining me I appreciate you hanging out and sticking with me through some technical issues I will see you again on Monday the 12th of least 12 13 13th of July where we'll be digging deeper into the array util script include there's a few things in there that I didn't know what they're for and I still scratch my head on one or two of them but I will enlighten you on what I thought I knew what was in there very commonly used script include and I'll shed some light on that and give some examples of how we can use that so look forward to seeing you 2 p.m. UTC Monday July 13th it's my sister's birthday I should remember that and I will see you again real soon until then take care bye [Music]

View original source

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