NOWCommunity Live Stream - Topical Deep Dive - Reference Qualifiers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [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 senior developer evangelist at servicenow and i am here to talk to you about reference qualifiers today this is the 30th of july 2020. we are almost done with the month it went by so fast but there's always august to look forward to and we are getting closer to well leaving the the rubbish heap behind us let's go on forward with the rest of the intro while people are joining up remember if you want we offer this on youtube there are now hundreds of these episodes out there i invite you to watch them subscribe to the youtube channel for the community there is lots of great content out there aside from the community live stream we've got the mobile app academy that is it is just starting up had a discussion with charlie yesterday looking very much forward to that so if you don't see me doing too much mobile it's because i'm leaving it for the subject matter experts over there on the mobile app academy same channel different content we've got open office hours for performance analytics and reporting that's why you don't see me doing much of that my focus is really on the core development topics on the platform whether they are no code features i'll show you some of that today or right on through some more complex things involving encoded query strings and whatnot so thank you to everybody who's joining me i see lots of familiar names and lots of new names jumping in if you want to see this live it is 2 p.m utc you do the math figure out what time zone that is mondays and thursdays so this is our thursday episode on reference qualifiers we also do this on twitch over at twitch.tv now community if you want to catch it there for whatever reason sometimes youtube a little misbehaving going on but uh it only sticks around for a couple of weeks on twitch but it is eternal i also have a local recording so if everything goes pear-shaped we can always upload that mp4 and you can watch it later so stick with me it's been known to happen things crash one man show just me here changing the titles and moving on inviting you to go to the developer portal where you can get a free personal developer instance now running paris or if you want to practice upgrading you will get an orlando instance from the previous release that came out in the spring and bring that up to paris to practice and see what it looks like and get familiar with the new features had a great time with andrew and jace on their webinar yesterday exploring some of the paris features invite you to go take a look at that uh it's uh i've i have to remember what end i'll put a link in here for andrew's channel to get him to get you some love over there but uh all the apis the the free learning plans everything we'll probably be referencing this more than once today if not we'll be referencing the docs so again invite you to sign up it's totally free you get your own private instance if you make it go crazy you can always z boot it that's what we call resetting and wiping z boot it and start over and do it all again in fact it's probably getting close for me to z boot mine okay the community is where you want to ask questions that aren't related to today's topic so i've had this in the past some people have asked questions in the live youtube chat and unfortunately i'm not able to to veer off the current topic we've got a lot to cover today and i want to make sure that it's focused on that topic this is not a live fire type of show where you just keep asking me questions and i'll answer them as they come sorry that's what the community is for because it's a great system of record and other people with similar questions can come along later and search for those so post those to community.servicenow.com that's what you see behind me that's what inspires a lot of the topics for this show and that's why i do it this show is also posted back to the community so if you can't find it you can always look for reference qualifiers or video colon now community reference you'll find it not a problem i do need to make a master index of these shows and topics you can find those i've done that with tech now before so uh whoo getting uh getting right up there the meetups are one of the things you will find on the community and if you drill into them you'll go to meetup.com there's the url there encourage you invite you to join one of these meetups and it's easier than ever because you don't need to drive or fly to a meetup nearly all of them in fact all of them that i know of as of today are being held virtually we've got one in minneapolis tonight we've got one in phoenix next week we've got one in madison next week we've got some that are lots of people around the world sharing their love and knowledge of servicenow and learning from that too so invite you to go over to meetup.compro servicenow dev program where you can find out more about that quick reminder we covered this first time on monday tell us about your app what apps are you building out there in servicenow that are either extended from hrit customer service management or you've got a new bespoke application maybe you've built something to help developers build applications you built a tool set tell us about those we'd love to hear from you by going to the bitly link you see on the bottom and as a result we will donate fifty dollars to as you see the un covet 19 response and recovery fund so up to five times we'll get you up to 250 dollars that you can help the larger cause simply by sharing what you've built what you've learned when i was a customer i did this and look where it got me hey better than 50 bucks i'm not probably seeing the same career path but i do invite you to go over there also want to invite you to sign up for and subscribe to our new developer podcast we've got one whole episode out it's episode zero that simply tells what the podcast is about it will soon be listed on most popular podcast directories we're in the process of those submissions and approvals and getting that listed so it's called breakpoint and i realize breakpoint is also a tennis term for those of you who also play tennis apologies for the confusion but breakpoint is also a place where you stop your code from executing in a debugger and inspect variables and check things out make sure they're running right so we want to give you a deeper dive into conversations with our product managers about specific things and and insights and back room stories and then also talk to customers about applications they've built and challenges they've had and how the platform has helped them overcome that every other wednesday the first one will drop uh the first official one is august 5th that's less than a week away from the time we're recording this on the 30th of july wow my brain just went into september for whatever reason so invite you to do that i'm very much looking forward to that it is you could say this was 15 years in the making because that's when i started podcasting and i'm able to finally take my podcast to work the web streams have been fun trust me they they're a lot of fun they're also a lot more complex because you've got lighting and cameras and whatnot podcasts to this it it's audio only this is easy so no demos no power points just conversations and very much looking forward to bringing you that very soon also want to remind you that we have our next tech now already scheduled and you can go sign up for that over at bitly slash tn78 reg we're going to be bringing in wolfgang wedemeyer who is one of our software engineers around now components and he's going to show us how to build now components and put them in the ui builder and whatnot so that is going to be a very productive hour i know there's a lot of interest out there around building uh now experience components and putting those on he's gonna get us started on a lot of that stuff i'm a neophyte with that i've seen it done a couple of times i struggle so i want to know what these concepts and processes and all the different files are for them we'll bring you up to speed on that too very much looking forward to this i know our hardcore developers are going to love this as well as the the no coders who know how to place these components on the uh excuse me the ui page coming back from that i don't think we're going to be building any well you may have a little javascript today but if i build any javascript it's going to go into this excuse me i always get these backwards for whatever reason let's do that the other way around then if i build any javascript it's going to go into this github repo if you want to learn more about javascript you go to the url on this slide over there a whole bunch of javascript lessons pass this on to your colleagues who want to go from admin to developer or are new to the now platform and want to learn how to do that so we'll put any code that we write in here a lot of it is going to be examples that i've got from other apps that i've built in the past but i'll try to share that just as an example so you could say oh that's what he did okay make it easy to follow along let's get started then shall we now that we're all here and having a good time we're going to be talking about not to the meetup page let's get the right pointing device and go to servicenow this is my developer instance running paris that i got from developer.servicenow.com gotta throw the bell in there whenever you reference a website uh good morning everybody lots of great faces and i could see faces lots of great games hopping into the chatroom okay want to start with what is a reference qualifier by backing up to what is a reference field i know this may be very basic to some of you but reference fields are very powerful and if you don't understand the context of what they are and what they do then it becomes kind of tricky to understand what a reference qualifier is so i am going to start out with one of our favorite tables in the platform incident and take a look at our open incidents list come on pdi there we are open up a record and you can spot these in an instant because they have this little eye icon next to them most of the time i won't say always because it might be read-only this says collar is a reference field has a magnifying glass so you can bring up a window and do a lookup and go through all of these records and pay particular note to this part where it says all up here in the filter you can build a filter just like any other list but it may already be pre-filtered which you have no control over okay there's another one down here you've probably seen this assignment group over here and assigned to these are reference fields each one points to a different uh it points to a table okay so if i say show assign to it's going to tell me a little bit about that it says this field is on the task table it's called assigned underscore two that's the actual database field name it is of type reference that means it's going to contain a unique identifier 32 characters of hexadecimal stuff it's not pretty to look at but it means something very significant to the system it says which record in that table we call them a society other systems referred to as a guide you take your pick okay this also says what table it references and notice this part reference qual that is a qualifier that says i don't want all the records i think i've got 600 and some in my assist user table you probably have way more in your organization's instance do you want all of these records the ex employees the current employees the people in sales the people in finance in this case it says no i only want the ones that have this particular role and i will show you the various places we can configure that the maximum length is 32 because it's 32 character society it also has a dependent we're not going to worry about that today let's take a look at this other one we've got a service we've got a configuration item more reference fields sometimes fun is to poke around these things and explore what do they do how are they configured have you ever looked at the show field look at this one okay it's on the task table field to cmwbci points to the table of the same name don't get those confused and this reference qualifier has a whole bunch of cool stuff in here okay keep that in mind this is an advanced one it's using some script it's not as simple and we can see any dictionary attributes on there as well so lots of neat stuff in a reference qualifier let's put that field away i'm going to unzoom for a second while we go and look at caller which is probably going to be very very similar incident table this one is not on the task table it's one level down on the incident table we should probably get into table hierarchies and extensions and all the cool things you could do at that at some point this one is called caller underscore id notice the field label is caller but the field name is caller id you've probably run into this if you've if you've explored around a little bit this one does not have a reference qualifier aha so i could potentially pick users that are no longer with the company that's terrible why would anyone want to do that okay so that's done zooming in on my form that's a basic orientation of reference fields let's take a look at the reference qualifier now there are three classes of reference qualifiers i must have moved my monitor because there's now something in front of the chat window that i just am having a hard time reading so i apologize if i can't quite make out all your questions on incident form we have a configuration item field we want to display data from multiple cmdb tables with the different filter conditions based on the status values okay i'll get into that in just a little bit we may be talking about dictionary overrides we may be talking about something else we may even have to go into an advanced reference qualifier i'll give you that uh look uh our reference qualifier became so big that it is taking greater than 100 seconds to load that would be a problem the reference qualifier shouldn't take that long because it's filtering down the number of records but if you've got a performance issue you may want to take that up with customer service there may be an optimization we can take a look at there okay on with the simplest of the simple i noted that caller incident is in global so let me change my scope to global so i can actually make some changes on this caller has no reference qualifier how did i know that well if you were watching a few seconds ago there's no reference qual in this so let's go to the dictionary i can get there in a number of ways i need the dictionary entry for this field each reference qualifier operates on each field okay i'll cover something on monday on how to do this a little more globally but the caller id field may have a different filter than the assigned to field they're pointing at the same table says user like that okay but they have different configurable attributes one of which is the reference qualifier they're different fields they have different dictionary entries so let's take this approach and say right click configure dictionary you have to have admin access to do this so be warned if it doesn't show up you know why wait for the pdi to bring us up the dictionary entry and i see i've got a type reference that's good that's what it told me the column label and the column name there's some attributes in here i'm obviously in the advanced view let me go to must be advanced because it's got some other things all right notice down here because it's a reference field i have a reference specification section it says i want to reference the user table now remember there's two user tables out there with the label user there's sys underscore user and there's imp underscore user one is for import sets don't use that one you won't get a whole lot of people out of it and the reference qualifier is currently simple i've got three choices simple dynamic and advanced let me zoom in on that so you can see it better on your mobile devices if you happen to be watching that way well that didn't zoom in very well simple dynamic and advanced let's start with simple defaults to simple there is no filter on this reference qualifier condition which tells the reference field go get all the records i'm not filtering anything in or out if i put in say something like active is true then i'm going to get fewer records let's go experiment with that for just a second i'm going to go back and prove this this is a demo moment whatever i can do this right click configure dictionary bring that out on a new window nope okay well that was fun go back to my sis user table in fact i can do this just by looking at the count apologies poor demo here if i click the magnifying glass it says 615 records that's all the users in my system and if i were to look at these i would see let's see if i can find the one that i was looking for uh lmnop i think it's akib aq i've got a few users in here that are no longer active akeeb is inactive so if i click on this icon to show it says hey guess what akeeb is not an active user meaning you probably left the company meaning you probably don't want to bring him up in this list so let's change that configure dictionary leave because i made some changes that's fine and go down here to simple set it to active is true and update it okay obviously you'd want to make sure you have the right update sets and all that stuff so it's captured and you can bring it over to prod but i'm doing this just for a quick demo to show you what it looks like now if i click the magnifying glass i don't have what was it 619 623 something like that it's now below 600 596 and i cannot pick akib anymore names that start with aq comes up with nothing it's filtered out i have no way to choose that if akeeb was already in that field it's not going to do anything until i try to change it and say you can't pick i keep so he can't be selected from the reference field because he's been filtered out he doesn't match that condition criteria of con active equals true and yes you can stack these up just like any other list say active is true department is i t manager is so and so you can you can really filter these down to any way shape or form you want it is dynamic so if the data on the back end changes your list will change you don't need to do anything to rebuild that list and by putting that on caller as i mentioned assigned to's reference qualifier doesn't change it's pointing to the same table but it's got a different set of attributes all right what if what if and this this comes up a lot when i'm making new applications extended from the task table because if i look at the dictionary entry for assigned two all right and i want this one says rolls equals i tilt this bothers me to no end because it's it's hooking everything into an itsm mode and many of my applications have nothing to do with itsm you're saying chuck that's getting in the way now i don't want to change it for global the global task table because that will modify everybody change and problem and incident and but i'm writing this new application for a legal department and assigned to is being filtered on this role that has nothing to do with the legal department how do i get rid of that this is where dictionary overrides come into play so at the bottom of the assigned to field i've got these related lists and i can override many of the attributes that are up here including the reference qualifier so let's take a look do we have one on incident yet let's say table equals incident and it says no you do not okay but i do have one on my cls to do the community live stream to do application it's in a different scope but i can still see it here it says yep the base table is task your table is the to-do table the column name is assigned to these automatically get populated for you the reference qualifier has been overridden look right here override reference qualifier turn it on what do you want to override it with nothing i don't want to filter okay that's that's the point get rid of the filter so i put in nothing and it says all right no filter for you and it works and allows me to select any user in the system now i could go back and say well how then do i put a simple reference qualifier on there you can put it in with what we call an encoded query string this is this introduces a new topic let's say i just wanted the active people in here how do you know what that magic sequence is that was easily built in the condition builder ah that's where we come up with things like the filter tool this filter tool is so powerful for building these queries there is a documentation page on here at docs.servicenow.com look up encoded query strings you'll get this page it allows you to create simple things like active equals true this is what the system uses as a meta query string if you're a sql expert it's going to be the where clause but it's in the service now language that's database independent so if you happen to be on prem and you're running oracle it gets translated just fine it's a middle layer to this database filtering stuff you're not writing direct sql statements you don't have to be a sql expert which is good because a lot of people aren't i i'm moderately savvy in sequel but that aside there's the roles equals itil that we saw before these come up as not sure what i selected there or backstring or whatever it was you can join them together active is true and rolls equals i told you whoa this is starting to get crazy with some up carrots and other crazy it's it's uh getting a little scary chuck you can un-scary it by going to the list filter here and saying oh there's one let's say active equals true yep that's my filter right click oh that's all i can zoom in right click and say copy query and it says your query has been copied to the clipboard and i can prove that by going over to my favorite text editor and paste it in it says active equals true therefore if i wanted to modify the dictionary override for this assigned to field to only include active equals true paste that in and now it will behave with only active users just like the caller field did so easy to do if your query gets more complex we'll get into this in just a minute so that's simple reference qualifiers and dictionary overrides let's take a look at the next type i'm not going to update that i'm going to go back to well you know what i'm going to stay right there okay there's another one that you may have seen this was introduced ooh 2012 2013 i think it was around the aspen berlin calgary time frame called dynamic filters i've got a page for that as well dynamic filters allow you to create exactly what it sounds like dynamic filters is this assigned to me let's take that case for example very powerful one well back to our friendly list view go back here and get rid of the filter and look for things that are assigned to me now i could bring up the filter that says assign to is me okay very wonderful very easy to do however it's static i can't give this filter to say john and say john here are all of your records because this url this query will bring up specifically assigned to me if i say copy query and paste that one into it and look at it this is kind of fun sometimes if you want to decipher what queries actually do this is my sys id on this system so doesn't work for john if i open this filter this shows up at the bottom of the operator list is dynamic and it says choose one of these dynamic filters oh it's me what that does to my filter is still says up in the breadcrumb assigned to chuck tomasi but if i copy the query it's actually using assigned to dynamic there's this new meta keyword in here and uses the sys id of another record to go run a little script now the way we used to do this in the good old days before dynamic filters before we had this option at the bottom is we would put in here javascript colon gs.get user id i've written that so many times in the last 12 years well until dynamic filters came along it's a neat little trick to know that says go run this little piece of code and substitute the javascript bits in here breadcrumbs still says this however query see if i can get a right click to work on this thing today there we are this now says the actual code these two that i highlight here are functionally the same this one gives me greater flexibility it's less like less prone to errors easier to change globally if we need to introduce another uh factor in there all it's doing is returning a society that's all it does it could return a name it's something to complete that condition so that i have an equality on both sides it's not returning the full encoded query string i'll get to that in just a little bit that's where we get into more advanced reference qualifiers if you want to build a dynamic filter it's right under dynamic filter options under system definition over here let's leave that we haven't changed that and we see all it's doing is returning a value like current name let's open up one of these records maybe i can zoom in a little bit for you on that so label that's how it's going to show in the drop-down list the script this is a one-liner okay it's not something equal something else is just what is current.name and current would be appropriate for something that has access to the current object gs.getuserid let's go take a look at the other one that we had let's find it it was simply called me which is very easy to remember and if i look for me in here i've got two one down here is the one i was using i'll tell you how i knew the difference in just a minute but here's the script that it wrote it says label is me script is gs.get user id exactly what i did before but in a more dynamic way because i may need to change this from gs.getuserid maybe gs.getuser.getusername or lastlogin or something else to make another one i could i could change this filter to say show all we're assigned to is something else i need i need a cis id and this is a great way to get it it works on the cis user table okay so we got to have that match so that it knows which filters to apply when you're doing the is dynamic it says oh you picked a reference field that goes to this user so here are all the filters that go with this user i'm not seeing things for cmdb and other crazy filters in the dynamic list because they don't apply to that field it's very smart that way over on the side i've got three options here available for filter is the one that i was using it's used for a list filter it will show up is dynamic and this option will show up available for default still haven't figured out exactly how to apply this yet but you can set this as a default value in a dictionary entry i don't know where you set dynamic fields in a dictionary entry because if you remember look at incidents go back to my dictionary entry for caller and configure the dictionary i have a default value ah there it is okay it used dynamic default so i can put in a dynamic default based on whatever a filter like this looks like i don't use these too much but it's nice to know they're there and the final one is use it for an advanced reference use it as a reference qualifier ah we just set that in the caller id we want active equals true well instead of active is true we could say assigned to is dynamic and it determines whether or not this shows up in that list of reference qualifier dynamic filters very easy to build very easy to use consider these when you just need a value for that particular field dynamic filter options can be very powerful things there's already a number of them available on a baseline system out of the box if you want to call it that some of them call an entire script include method some of them pass parameters go exploring through here there's only 84 of them shouldn't take you more than 10 minutes get familiar with the common ones that you're going to be using on those task tables or the task fields so before you go start writing your own i think the most common one is me because you can also use that on a filter module am i still in cls323 sure let's let's go with that let's go to here and say i would like to edit this menu brings up my application menu create a new module and i don't have any in here right now but if i were to create a new link type list of records on the course table and say that's the approval field program doesn't have any dynamic filters available to it so it doesn't even show it in there ah rats i thought i had a name field in here a cis user field not in that one oh to do would have one i could put one in there so this is where you could also put this think of things like hey is it assigned to me you could put this in and now you've got a dynamic menu option very common thing to do for task-based tables is show me all the stuff assigned to me you build a dynamic filter and regardless of who clicks on that module it knows who it's assigned to who's who's driving this browser and who do i need to substitute in for that cis id all right the final one is the big one advanced reference qualifiers and if i look under the reference qualifiers page this is a paris page i get simple reference qualifier dynamic reference qualifiers we've been through that look at how much stuff they they line up for us on that and advanced the key to an advanced reference qualifier is getting that encoded query string right trust me i've written some dandies in my day these are very powerful things on the dictionary entry you would put in the reference qualifier advanced and then you call some script or you set some string to that value if you want to run some code you got to use that javascript colon prefix that i showed you before let me give you an example of where i did this before some of you may be familiar with this application it is my good old-fashioned loaner request system so i bring up studio i have file switch and i happen to have the one that's available on the share portal right here plus or minus a few tweaks that i've done on this show and it behaves let me show you how it behaves if i go to the loaner request and i have a whole bunch of contingencies in here let's show you what it looks like before i show you how it was built the thought is i want a list of cis items that i've designated as loaner capable for this depot i think i clicked that did i not i've got a depot where are you going to pick it up i'm going to pick it up in atlanta when do you want it between these two dates what type of item is it it's a laptop i've got all these variables on the form that i need to find a slot and show me only the available items in that location for those dates how's that for an advanced condition you're not going to build that with a simple filter and it has to be dynamic so if i change the date it now goes and looks at a different set of data it's pre-filtering this for me so when i pull up this magnifying glass it only has the items in the cmdbci hardware table or computer table excuse me that match those conditions i have two that currently match those conditions and if i change this to chicago i don't even have to save the form the reference qualifier already knows that these are my i can tell from the the ci name that it is loaner chicago down here lnr chi so it can be dynamic to the form very easy to do or if i start typing lnr it goes yup i got a couple for you in chicago it's pulling all of these parameters together to filter that list accordingly to me because i don't want to schedule the same thing the same item to two different people at the same time that would be a collision that would be bad it'd be like getting on the airplane and saying hey you're in my seat and the boarding pass says no i'm on flight 749 i know we're not traveling a whole lot right now but this has happened to me before someone says you're in seat 6c and well my boarding pass says 6c and so does mine that would be a bad situation so the airline has something very comparable to this somewhere in their back end logic when you're picking a seat and booking a flight or at the gate when you're asking for a seat i want to know what's already taken on this flight for this anyway you get the idea how was that built well i started out going back to the list and i said i want to see let's go to cmdbci hardware i want to go to the table where that is listed a computer excuse me actually i i do even better than that let's leave that it's actually the table references cmdb ci dot list okay out of all of the i know your c your cmdb probably has more than 2 700 items in it i do many filters on this first i say is loner true so i say this has to be true i don't want to see ci's there in a server farm or network switches or software that's loaded on somebody's computer that's not loaner equipment i don't loan out switches well maybe you do but i don't not in this scenario and the depot is atlanta okay i added those two fields to this cmdb table to facilitate this application they are specific to this application and the item type or class is computer get down to computer i'm hard coding one of these queries so i can see how it's built and then i can computer there it is and then i can start putting in the dates for my request but i don't have the request yet i'm simply looking at a list of these things is it the right item type is it the right class and is it the right location how many of those do you have okay i have two great what does that query look like to me copy the query and go take a look there's no great mystery on this stuff it's pretty easy to decipher okay a little few scary field names in here but i'm on the cmdbci table so the field is called x under loaner underscore is loner equals true well we can decipher that up carrot means and i'm joining these together all conditions must be true in this case and the depot is atlanta if this were a reference field it would be a society it's a choice field so i get the value and sis class name which is the table name so when i picked laptop it actually had a value in that choice list it said go look at this table it doesn't say laptop and then i translate it somewhere it's automatically translated for me good use for choice list when you want a friendly label and a backend system value sys class name is computer once i understand this i can now start putting in parameters and say well hey i know what that is that's current dot cmdb no i'm sorry it was item type item type dot get value or value or whatever you want to put in there okay you can start putting in your variables your parameters for that and then turn that into a script i've got a video on this on the community of how to do this especially for an advanced reference qualifier but in the interest of time i'm going to do the cooking show thing and show you what one looks like already baked i have my server development and let first let's take a look at what that reference qualifier was i think we've got too many windows open right now i'm going to go back to my loaner request 1002 and this is my cmdbci field with a new label applied because people running our loaner request don't know what a configuration item is but they do know what an item is could be a projector could be a mobile phone could be a computer or whatever let's show that and woohoo look up here i got all kinds of cool stuff for me it is the cmdbcit field off of the task table it is a reference to the cmdb just like the configuration item on incident same field same table but i have a dictionary override in here i already showed you what a dictionary override is but instead of hard coding active equals true or x under loner is loner equals true something of that nature i said go call this script that's all it does if you go into the dictionary entry for the cmdbci on the task table there will be a related list entry for my table x under loaner under request that says thou shall override the reference qualifier just like i did before but instead of making it blank i'm giving it this little javascript okay so what is this scope dot this script include i'm reverse engineering for you well that's available right here under script includes oh look there's loner ci ref qual i rebuild this today i wouldn't do it quite this way this was a holdover from the global business rules days don't use global business rules kids put them in a script include it has one function and one function only this function a must must must match the name of the script include that's how this works and that's how it was converted from a global script include a global business rule all right it does a couple of things it says go instantiate the loaner utils well hey there's another library full of stuff that it's using which we'll look at in just a moment i pull out the value of the depot field i pull out the volume of the item tape and the table in a little different way i'm not sure why i didn't use get a get value on both of these this is very very old code and needs some cleaning up i'm not proud of what i did the answer it returns is the queer encoded query string now my encoded query string is going to go build these values dynamically because i have to look in two steps first find out what cis are in the class and the item type and the depot that no class and item type was redundant the item type is the class the depot those three things i looked up before is it a loaner is it in this location and now is it available is the second step so i need to look through all the other requests that are bound by the time frame that i suggest that's a simple little glide record query so this thing simply says is the cis id of the records i went and looked up list the ones that are there that's how i do that i could build that in a list filter if i wanted to but it's not very fun to type sys ids but if you know them you can test them this becomes very very easy to use i could also run this from scripps background to test it if i had a current record for me so let's go get one let's say this is current and i'm going to copy the sysid this is how a unit test my script includes by the way go to scripts background and let's put this in here var id equals some society and then we will call our current this is called a faux current new glide record record table name is x under loaner i don't have a constants on this one it way predates my constant thing so i got to remember the table name current.getid and now i could say our a answer i don't know let's make sure we put the scope on there just in case we're not running from this scope it was the same code that runs in my reference qualifier which i can't remember at the moment so let's go copy it show that is going to be xlonarlonercif call back to here and i thought it passed current but i guess it doesn't oop bad scope on there and we will do gs.info may let's find out if this works i'm not confident this will because of the way this is set up paste that let's just see do i get my reference qualifier my encoded query string out of this the answer is yes yes i do it's right up here sysid in this id one society2 that's what gives me the two records in that reference window all i'm doing is creating an encoded query string and that was done in a couple of steps that i will show you because this calls available cis out of here which i know is at the bottom this is the way i did things before i had a constants okay don't do that up in the initialize it's great for something and available cis is right here take a look at that code i think we can see most of that starts on it says i want to look at records on this ci table if the status is installed i'm building a query okay i passed in the class name cmdbci computer cmdbci phone cmbci vehicle whatever your table is that you can go look up the depot name atlanta chicago sydney that kind of thing and the two dates that's my bounding box to see if anything overlaps or conflicts or is checked out and i'm going to get all the available ci's that match that and put them into an array called available items just push that in and i return that okay that's getting me the available cis what good does that do well once i know the available cis available ci's also calls is available how do you know if it's available we have to do a little time comparison over the record that's the next function up and check this out is available has another encoded query string being built in it that includes the date fields how did i do that same way went back to the list field built it up manually with dates and then put in my parameters this one's even got a big ore condition right in the middle because i want to check if something overlaps or if it's currently checked out and hasn't been returned it's not available it's overdue if something's overdue i can't release it to somebody else i shouldn't be able to pick that so watch for those kinds of conditions also just taking queries looking up records seeing if they overlap and building this list of cis ids advanced reference qualifiers very powerful yours may not be as complex as this but it could be and it's used to filter down what people can pick or what they can't pick so looking real quick see if we have anything in the question looks like there's a discussion going on that i can't quite read i'm definitely going to be moving that monitor just a little bit to the left so i can read it on monday until then that's all i've got for reference qualifiers let me see if i have hit all the buttons i want to hit advanced reference qualifier is yup yup yup so think about using reference qualifiers keep people from picking the wrong thing on those reference lists they are unique to each field i will have a supplement for that on monday's show so i look forward to talking to you on august 3rd for before query business rules okay very helpful very complementary to what we're talking about today and they also resolve an annoying user interface thing but they can get you caught as a recent customer just discovered they they can be a hidden landmine going why can't i see anything i'll show you that on monday look forward to talking to you then uh until the third take care i invite you to participate in the servicenow community going to move my screen around here at community.servicenow.com that would be over here go check this out if you've got questions that go beyond the topics we discussed here or if you've got comments about this post them in the youtube uh description or the comments on the youtube video for this or again in the community we've got uh comments there as well thank you very much for joining me i'm chuck tomasi from servicenow and until next time i hope you have a chance to learn something share something and be helpful take care bye [Music] you
Info
Channel: ServiceNow - Now Community
Views: 2,443
Rating: 4.9166665 out of 5
Keywords:
Id: I7ZNPyrWCuU
Channel Id: undefined
Length: 49min 50sec (2990 seconds)
Published: Thu Jul 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.