logo

NJP

Community Live Stream - Topical Deep Dive - Dictionary Attributes

Import · Sep 10, 2020 · video

[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 servicenow senior developer evangelist today is september 10th that's right september 10th 2020 and our topic today is dictionary attributes something you may be familiar with you may not be familiar with either way i'm going to take you from the start show you some examples and maybe a couple of tips you didn't know about that you could use in your application or fields or some dictionary entry somewhere let's get on with it this show is brought to you mondays and thursdays at 2 p.m utc well save holidays like we just had so hope you had a chance to catch up on some of the past ones head on over to youtube the url that you see right there click the subscribe to like the notifications you know what to do much appreciated and you will get lots of other great content from the community that is useful a lot of people signing in this morning on the youtube chat thank you for joining me live we had a little pre-show discussion got some great ideas thanks for joining i see everybody jumping on you know to do if you've got questions or comments after the fact put them in the description this video is also posted back to the community and you can find that on the community by searching for community live stream how's that for an easy search i need to really make a playlist on the community somewhere but there's one on youtube and there's a link to the community article in the section so anyway twitch similar kind of thing you can go over to twitch.tv now community and watch those videos there they'll be around for a couple of weeks if you do have questions that go beyond today's topic we're talking about dictionary and dictionary attributes today just the attributes not the whole dictionary entry just the attributes that's a pretty specific topic and if you've got something that's a little more general or outside of that discussion topic please go over to the community that's what you see right behind me where there are tens of thousands hundreds of thousands of people that can help that can benefit from your question i've had a few people asking me questions on linkedin i don't do that because it's a one-to-one discussion and really you're the only one that benefits from that and i apologize if that sounds a little uh rude but i want other people to learn other people to contribute i want you to get an answer faster and frankly i'm very busy right now that i don't have time to answer every question that comes in via email or linkedin i apologize you know if you need immediate support you call customer service you want crowdsource support you go to the community you get some interesting ideas so i contribute on the community when i can unfortunately it's not all that often right now outside of these videos so community is your best bet if you've got questions about the platform about applications about development about reporting security it's all right there so go check it out the developer portal if you haven't already gone there over at developer.servicenow.com is where you can get a free personal developer instance i know many of you have done that thank you very much there's many of you who have not this is a great sandbox somebody said hey chuck i'm testing out this application that i got from share which is a bunch of shared applications and utilities and integrations available on the platform on the developer portal and they said does it work in orlando you know what i thought i tested in orlando but if you want to be sure you could go get an orlando instance from the developer portal set it up run it have confidence have fun test it out it's a great sandbox environment when you're done you say i'm done let it go i don't need that instance anymore great way to test things out without impacting your organization so a lot of people checking in thank you very much for joining one of the other things i invite you to do and there are many of them are developer meetups whether you are just starting out or you're a seasoned veteran such as me developer meetups are a great way to interact with other servicenow developers all of them are being held virtually as we do this in september of 2020 for obvious quarantine safe social distancing reasons work from home that whole thing i will be actually presenting next week in the amsterdam meetup so i don't have to travel and i invite you to join because you don't have to travel makes it a great way to share ideas and concepts and ask questions of other developers whether depending on where you go you will get a different expertise you know if you go to uh you know i think it's the minneapolis one you'll might get one of the tolson's sarah or travis and get to ask some service portal questions you go to another one you might get some more in-depth questions about implementing a cd cmdb so and i invite you test these out try them out you save on travel and of course you know the timing has to be right there are some that are meeting in the middle of my night which makes it a little difficult for me to attend and still put on a pleasant face you have to put those two qualifiers together i could attend or i could have a pleasant face but i might not be able to do both in the wee hours developer meetups are where you can find that we are still looking for your stories around servicenow applications that you've built please tell us about your applications at bitly slash tell us about your app and for every app you contribute we will donate fifty dollars to the un uh covet 19 response and recovery fund up to 250 for that thank you for those who have uh already contributed their stories very much appreciated and we will get through this as soon as possible if you haven't done so check it out only takes a few minutes and you could be helping someone another reminder breakpoint podcast is coming out i just talked to one of our product managers yesterday tuesday i don't know what day it is anymore tuesday i think it was no it was last thursday and i gave her the video onto the audio on tuesday sorry i'm all mixed up it's crazy time especially with four day holiday weekend that was fun stuff did some software upgrades so if things go a little haywire you know why the listenership is growing thank you thank you for everybody who's been subscribing and listening to that there is more content coming out i think if i got three or four for the month of september it's supposed to be every other wednesday but everybody keeps asking me can we do this can we say can we work on this yes yes yes it's all wonderful stuff breakpoint is the podcast if you are again just starting out or very experienced or somewhere in between or you're curious about this have a listen it's it's just conversational 20 or 30 minutes i talk with servicenow people i've got a special guest coming up in october that we're going to talk to about what they've built and how they built it and that kind of great stuff so keep a listen for that you can find that over at bitly slash sn dash point we do have a tech now coming up wow there's a lot of stuff i don't know i don't know how i do this but somehow it all gets done this is my job to bring you wonderful information and one of those wonderful informations is going to be about the upgrade center in paris and how it can make your upgrades much much easier as you go forward the challenge is you got to get to paris to get this benefit but hey going forward if you want to install paris patch one or paris patch seven or quebec or on and on and on this is going to be a wonderful wonderful addition we're going to talk to jim jack cower about that and get her inputs and insights and a demonstration and a tour we might even get into a little bit of atf she takes care of some of that wonderful stuff go over to bitly slash tn79 reg i try to make it easy for you to remember so it's easy for me to remember i got to keep the herbal tea going this morning where are we on the lineup we are going to be doing a little bit of scripting today just a teeny little bit to show you something interesting and this is kind of what kicked off this whole topic i was looking through some of the apis and went i didn't know about that we better share that so i will have that in the github repo that you see there bitly sn-cls you can find that and all the other scripts you've been doing for the last couple of years in that repository in dated folders if there's no folder there wasn't any script that day we might have been talking about form designer hey no script no folder you get the idea uh if you want to know more about javascript and you haven't done so just a friendly reminder that this series has been out for over a year still holds up still works well you want to learn javascript from start to the point where you could actually take the course the javascript course and say i've never done any programming in my life or you're an ancient php programmer like i am you could jump in here learn the concepts practice them out follow along or just get a point reference and say what was the do while loop again walk me through that let's let's take a look at how objects are defined and declared and passed and all that good stuff there was a dotted notation and a bracket notation to that yeah you can do that in javascript so if you want to learn more about javascript go over take a look at that and thank you very much again for everybody who has done so it's turned out to be a very very popular uh series working on another series for you stay tuned there's stuff coming i don't again there's you know i see my calendar it's like work for this for an hour then go work on that for an hour seems like it would be a little more stable than that and let's get into our topic of the day which is dictionary attributes and i don't need that little password thing up there this is my personal developer instance edi i'll say for short over at developer.servicenow.com where you can find that and want to talk to you as i said dictionary attributes are sort of properties that you can put on a dictionary entry everything you see in servicenow is in a record and every record has fields and fields can have certain attributes let me give you an example one that you're probably very already familiar with if i go to the incident table and i take a look at the open incidents we'll just open an open incident and hopefully i reset my footprints around here i don't if we look at assignment group and you click the magnifying glass on assignment group it comes up with this list okay and you may have to scroll through here if you look at location locations not on here let me go to user administration users and i believe the location table here we'll pick dewey crow there's a location field in here uh it's not on the form let's put it on the form maybe it is no it's not let's put it on the form let's go to the global so i can modify this form form layout configure form layout thought i had this set up just a little bit better but i did this a few weeks ago so my memory may be a little stale waiting waiting slow browser take a drink time not quite uh the customer section i don't want the customer section i want sysuser dot list oh you know why because i have an extended table forgot about that let's pick one where class is well you know what never mind let's just do that again never mind it says it's in cls 323 we'll modify it in clf 323 configure form layout all i want is the location field on here waiting again waiting again come on there we are and let's put location on here because i believe if memory serves we'll put that somewhere up there on the right hand side get the location field what i want to show you is this comes up with a tree picker also a reference field but a different layout for this because it understands hey somebody said somewhere that i need to use that tree picker view whereas this reference field department does not okay so what's up with that well anytime i have a parent-child relationship in a table to the same table i could use this tree picker if i were to right click on this field and say show location it will tell me these various things about that field this field is on the sys user table it is called location it is a reference field to the cmn location table look down here we've got a couple of attributes one says encode utf-8 equals false means something to somebody somewhere not encryption if you saw edge encryption you know it but this other one that says tree picker equals true says we can use a tree picker all right so that's what's telling that field when you present that pop-up window use the tree picker and if we wanted to do something like that on our incident go back to our assignment group and right click show assignment group here it does not it has some different attributes and code utf-8 equals false and ref contributions equals on-call excuse me on-call escalation tracking oh that's different don't know about that if there is a dictionary attribute that you don't know about you can go over to the doc site and type in dictionary attributes and it will come up with your favorite release and it will tell you all about those what was that one called ref something something something that's my bad memory ref contributions oh i know what rough contributions are and the the actual one that it said was ref contributions field decorations similar to rough contributions nope there should be a rough contributions ui macro list separated by semicolons it's telling me i have a ui macro list and for whatever reason this one's called on-call escalation tracking there is no decoration next to this there is no reference contribution there is up here on this one caller has something if i show caller it's fun to kind of poke around here show a user show incidents okay so we can take a look at some of that stuff if i click user show incidents it runs a ui macro and says this user also has these other incidents so different attributes do different things let's go and turn on the tree picker for that one for that i need to go to global because this field is in the global scope i can say right click configure dictionary be taken right to the dictionary entry for that and i would see down here in the attributes list there is tree picker true well if tree printer is true on assignment group why isn't it working for me it may be that there is a dictionary override now this stuff you see up here on the top the type the mandatory the read only the choice list the default value a lot of this stuff is for it's defined for the task table but you me and all our friends know that we could have other tables like incident sc task a lot of other tables extended from task and by default all of the attributes are taken along with you okay not much wrong with that there may be a dictionary override on incident that is taking care of that for us look at this incident as a dictionary override for this field and it says override the attributes and that's where our reference contributions are coming from if we wanted to add the tree picker back in this we would have to say comma tree picker equals true typing is very important here i didn't i wasn't going to get to overrides yet but this kind of lit us on a nice little detective path now if i go back to this and i say assignment group it is by tree picker because i could have groups within groups within groups actually right now i have users within groups but that's okay i could pick the users that way i could pick the groups this way the tree picker is still working for me that's what dictionary attributes do now there's a couple of ways to set them i could let's not do assignment group because i know that it has an override let's do configuration item for example if i show cmdbci whoa look at all the attributes this thing has wonderful let's pop that up a little larger and take a walk through this in code utf-8 equals false we're kind of getting used to seeing that even though we don't know what it is if we want to know what it is we could always go over here and say oh browser find me in code utf-8 and it says i don't know what you're talking about there are some attributes that are not documented and for that i apologize on behalf of servicenow we can find out what they are somewhere else okay the we have one called ref ac columns ref ac order by ref autocompleter and ref contributions well we already saw what ref contributions was that's the ui macros that show up and there's going to be one that says task show ci map so when i pick a ci it's going to have a little icon next that says you want to see where this is in the cmdb map or what it's related to show related records i could have other records that are related to that ci some neat ui macros so ref contributions puts icons next to reference fields these three ref ac columns ac order by and ac auto completer often show up together there's several that are in here about ref under ac find ref under ac ac column says when i start typing in this field let's back that out put that away when i start typing in this field ibm it's going to show certain columns if i were to do this on the caller field okay fred it's going to start showing certain columns the name the email the address the company you decide you can tell it which columns to put in here the column search says by default it's going to search by whatever the display value column is but you could also have it searched by other fields in there maybe you want to search by email address maybe you want to search by employee id and start typing u2101 because somebody typed that into the chat or something if you do that keep in mind that it's doing more complex lookups at the database layer so if you've got 500 000 users and you start adding complexity onto this search it could take quite some time for you to start typing wait then it presents a list of results okay it could get a little busy okay you could slow down the performance by adding these okay so be careful as you do that the display value there's a ref ac display value order by says i want you to go buy a descending email or i want you to go buy a sending display name the autocompleter is a separate script generally everybody uses the same one you look at caller show caller no that one doesn't use it it uses by default ajax table completer okay there is a script out there called ajax table complete or script include that is used there's one called ajax reference completer there's one called ajax table completer they give you some examples in here of what you might see and what you can use this is the script that does your lookups for you so take advantage of that that is that is probably one of the most complex set of attributes you use is the reference fields and be aware as you add complexity to that you could possibly incur performance issues test on a very large data set to make sure that your users don't go this is really slow because somebody configured it to be slow okay normally it's not that slow let me walk you through an example that i've used a number of times i love the condition fields you've probably seen me use this it's on one of our previous videos condition fields sure we'll reload that condition fields i'm going to go to my cls you know what i'm going to jump into my studio studio so i can see multiple things at once and do some comparisons and i have this table called rule rule is a lookup table that has some conditions on it and one of the fields is of type conditions when you look at a cls rule you will see it looks like the condition builder that you've seen in ui policies business rules notifications you pick a table it shows you some fields you build a condition around this this is called p1 active incidents because active is true and p1 is true this field currently has no attributes on it right let's go put a couple on there that i love on condition fields if you didn't notice real quickly let's install these updates maybe tonight you didn't notice on the list it's showing it as an encoded query string not the most human readable thing however i can change the behavior of the way that field on that table is displayed by adding a dictionary attribute so let's go do that let's go back to studio open up the condition field and there's a couple of ways you can set attributes first is you need to go into advanced view if it doesn't have an attributes field on it it's probably not in advanced view the other way is down here in the attributes list that we saw before i can click new type readable i've obviously been here before and the value is true how do i know that because at one point i went in here and said tell me about readable readable is a true false when true causes rendering of the conditions field and any list view to be human readable condition instead of encoded queries stored in the database very nice i would like to represent this and i don't know why i would love to find our developer style guide because this should be the default in my opinion i don't know when it's ever useful to see an encoded query string on a list unless you're debugging and you just want to copy and paste but really that's not all that common it's more helpful to have this as a readable string so let's make it readable we'll go in here set the readable attribute to true and notice what else happens when i go to my dictionary it has updated the attributes field once upon a time about 0.78 years ago we didn't have a related list of attributes and all we had was the attributes text field this comma that comma this equals this comma semicolon very easy to get things mixed up if you messed up a dictionary attribute it could render your field useless you go to click a reference icon and nothing happens why not well because you jimmied up the dictionary attributes and it doesn't understand what you did so to try to eliminate some of that we put a related list of dictionary attributes down here to make it less likely i say less likely because we're now picking that like you saw readable from a reference field but we're still typing in t-r-u-e if i typed in t-r-u-d it would have gone okay it's not readable and you'd have to do some debugging so you can set these either way if you change this to false there's the typo false and save it will synchronize down here with false it will transfer that value if you change it in one place it will change it in the other so that's how the dictionary attributes work just for my sake though i'm going to make it back to t-r-u-e save that and go and test our results add that refresh this and active equals true and priority equals one critical much handier so applying dictionary attributes is very easy either way let's go do another one real quick on that same field we can add a second field by saying comma show condition count i can never remember this one with its row count condition count that's where i not sure why i clicked that i just sort of missed i wanted to go down here and say let's add a new one show condition count that's what it was and again if you don't know you can click the magnifying glass and go exploring through the 108 or apparently there are some that are restricted by security constraints okay show condition count true it's another one that i commonly use with condition fields they are comma separated in the attributes field and you can see if i scroll back up it's added this for me very cool i now have when i drill in here it will show me the field with this little recycle icon and the number of records that match that count not too bad sort of a pre-test to go how many records am i really going to get you may have seen this you may have not if you haven't seen this it's a nice little attribute to use on condition fields i use it quite a bit now that is a little bit the basics of where attributes are how to set them two ways to set them but i've got one more trick to show you before i let you go you can define your own dictionary attributes oh really he says yes oh really and obviously i wouldn't be able to pick my own from the attributes down here on the list okay let's say i want to create a a condition excuse me an attribute on uh that assignment group field i've extended another table called to do's to do is extended from task we'll close out these we're done playing with that and my assignment group field wants to do something special i don't know what that is something special this record is in the global application because it belongs to task but i want to put a dictionary override on my table well here's my table and i have an attribute called my attribute equals on what's it do don't know i'll figure it out later maybe it tells some script include or rest api or something to do something okay it's a dictionary attribute it only applies to my version of the assignment group field because i put in that dictionary override well what good is it how can i access it that's where ta-da like a cooking show i had this already available we can use the get attribute function method on a field let's go and see what we get out of this put that into scripts background which i have here and i know that this is my to-do table i'm going to just do an initialize you have to do something to get an instantiation of that record you can't just say new glide record what's it look like do an initialize do a new record do a query something to get one of those records in memory it doesn't have to be a valid record it just has to be a record so i'm going to say display the value minus not a boolean attribute mine is a string attribute so i'm going to start with get attribute there's two methods i want to show you here and i called it what did i call it my attribute equals on okay so that's over here my attribute by typing that correctly attribute only voice recognition worked and it says the value is on hey that's pretty cool right i can see if it's on if it's off it's a 100 if it's 3 if it's yes no true false ah but true false has a different method you may have seen it because i just erased it if i want to find out if it's boolean or not there's another method called boolean attribute these are documented by the way and if i say tell me if my attribute is on or off true or false it's going to say it is false and i always like to say hmm was that a string false or was that a stop scrolling did i zoom in i did that's why it's scrolling bar answer equals or was that a real boolean i like to stick in type of just to understand what am i working with do i need to convert it to a real boolean and it says this is in fact a real honest-to-goodness boolean hooray i don't have to do any type conversions it's returning the right thing but it is in fact false because it's not true that's what get boolean attribute is looking for if i were to go into my dictionary and say tree picker equals true and update that it would give me that tree picker that we saw before and now my script i'll say tree picker it's going to say let's just get rid of this and say oh i'm sorry it yeah it's a boolean i got my examples mixed up print out the answer and it says that is true so i can use this logic to extract attributes whether they're strings numbers booleans are very handy if you do get boolean attribute if you're using trues and falses use get boolean attribute anything else just use get attribute you can always do a parse int if you want the number value you're going to have to do that anyway okay so get attribute get boolean attribute i'm always looking for opportunities to use these new things that i learn i just learned this one recently i'm kind of thinking when would i use a custom dictionary attribute well if a field needs a specific behavior on a specific table that's what an attribute is for system properties change the behavior of the application in general they are meant to say what is my um what is my retention time reminder time how many hours between this that's how the application behaves it's going to behave that way whether you you don't want to go back to development to change a workflow or a flow or a business rule or script include with magic numbers societies group names put those in attributes that's the behavior of the application user preferences would be specific to a user okay you want to see 10 columns i want to see 12. you want to see the the number of incidents in the last 30 days i want to see it in the last 15 days that's a user preference thing because you and i have different if it's different between two fields on tables like task assignment group and my to-do assignment group that's a dictionary attribute and then we talked about session variables what a week ago i think it was the last episode or maybe the one right before that that's where session we've got all these different ways of doing that i'm going to put together a short episode on how these all fit together and when you would use each of these but dictionary attributes are for a field or table there are dictionary attributes on tables look them up go i encourage you i invite you to go through the list of dictionary attributes it's a fairly lengthy page but you will probably find something in here you didn't know before that you go oh that would be really handy i could use that or i want to know more about that look how many are here on ref ref auto complete or rough contribution draft decoration reference label ref qual elements ref sequence ref types okay you get the id scale script short label a lot of cool stuff in here i've got this zoomed in which is why it's formatted a little funky but uh dictionary attributes very helpful when you want to modify the behavior or the display output of a particular field so do we have any questions in here are attributes set only by boolean value no no as we saw we can have the uh the the ref lookup uh what was it the reference field that had the different fields that you could put in there how you sort how you order uh the number of things many of them are true false but many are not for example there's a true false here is a function that returns the contents of a field here is an integer here's a field name you get the idea different data types available to you there's only two methods that we've got for get attribute and get boolean attribute that return the booleans or everybody else yeah each attribute has its own thank you for answering that daniel does the order of the attributes ever matter if there are multiple ones on a field's dictionary entry no because they're all mutually exclusive and there's no conflict between the order of evaluation that i've run into i haven't seen like you have to set this one before that one uh and i don't believe i didn't see it in here let's go back to studio where i had the attributes down here ah let's just go back to my rule table it had a couple of attributes attribute excuse me rule condition i had a couple there's no order field on here that i'm aware of let's just take a quick peek yeah no order so if there's no order nobody cares it's just whatever it comes into uh awesome chuck thank you very much right in time i needed to do some assignment at work today i'm glad it worked out timely for somebody seems like there's always somebody that goes oh that was i was just working on that appreciate can we run scripts from attributes uh not directly i'd have to see what you're what you're thinking about again i'm thinking about possible performance because remember those attributes are evaluated and applied for a list if you had a list of 50 things you're going to have to run that script 50 times and that could be a performance impact so be cautious about where you run scripts especially scripts that involve glide queries there are attributes that reference scripts and you could do that but somewhere you would have to have logic that says go look at this field get the attribute tell me what the script is i'm supposed to be running so it's sort of a script running another script saying and we talked about that with glidescope evaluator i think we did grip fields we did script fields a while ago so okay that is all i have i invite you to join me on monday do i have my monday topic in here i don't have my monday topic in here let me tell you what it is let me look real quick because i thought i had it right here monday the 14th we are going to be talking about such a well-rehearsed well-oiled machine uh that api model that i was just talking about probably be a pretty short discussion so i'll keep the intro short but when do you use attributes and no i got that wrong that one is uh not there the api model is how do script includes and business rules and ui actions and client scripts and how does all this stuff fit together what is where should things go for easy maintenance easy building easy testing how can i put my script how can i put my coding stuff together optimally what are the best practices for that i know a lot of people ask this and i've seen a lot of scripts that i go that should really be over here or let's take that and move it that way i'll include service portal widgets i'll include scripted rest apis there's going to be a lot of information on that one so don't miss out monday the 14th we're going to be talking about the api model where does your code go and who talks to what and how that gets handled best for you and me until monday 2 p.m utc i look forward to seeing you again real soon remember if you learned something share something be happy contribute join in the community there's a lot of great stuff over there and i will talk to you again real soon [Music] you

View original source

https://www.youtube.com/watch?v=3uqqlnNwR2A