logo

NJP

ServiceNow - Record Producer Tips, Tricks and Scripts in Paris

Import · Sep 13, 2020 · video

my name is jason miller founder of aspen now solutions and we're about to unlock the power of service now like to start off by thanking all 3 545 subscribers in over 80 countries globally if you believe in transferring knowledge to those who need it most please click subscribe your user data will not be transferred to anyone outside of ask but now without your consent hey everyone it's been a couple weeks since the last video so i figured it's time to do another one just wanted to highlight this five new features in paris uh seems to be a hit everyone's liking it watching it um some cool content in there so if you haven't had a chance to watch it just go ahead and uh click down there and uh today what we're going to be discussing is record producer tips tricks and scripts in paris and i've been doing record producers oh i think from the very beginning which is a little bit over six years in servicenow and i figured you know what now it's finally time to share some knowledge with you guys regarding this topic and uh first off let's start out with like what's a record producer so record producer you might think of like p diddy or something like that no it's not a actual person the record producer we're talking about a form that someone fills out to get something accomplished in the servicenow platform so this is generally done in the uh service portal which you're looking at right now this is my service portal that i built out over time and we're going to be focusing out focusing on this aspen solution requests so click on it it's going to bring me into the form and you'll see it kind of looks like your standard online shopping form if you will if you want to think about amazon or something like that when you're setting up your account maybe you'll fill out your name location stuff like that whatever this is going to be more for like a request you can think of like incident you know something of that nature so for our first uh let's see here item that we're going to discuss we're going to talk about preparing the table first so this is a lot of people what they'll do is when they start out building um let's see here record producer they're going to come straight to the form uh build out the record producer by going to record producers on the back end so if they go to rdpr um they can come right here in a service catalog and they'll find record producers open up a new record and then they'll start building it and then they need to have like the back end so there needs to be a table that's built out but really i guess the the takeaway here is make sure you build out the table first with all the fields all the choices that are going to go into those choice fields or if it's referencing um you know another table and all that stuff work all that stuff out first and then what you're going to do is you're going to come into tables so if you type in your tables make sure i spell it correctly we'll come into tables i think i had to start somewhere it's like tables and columns might all the way all the way at the bottom uh there we go so it's under system definition and tables and that'll bring you in there and you can take a look at whichever table it is that you want once you click in the one that we're looking at i pulled up incident just for um you know an example but if i want to look at the specific table um this is aspen rp table and when i click into the table again this is incident here um when you come in you're gonna see like this columns and stuff it's a lot of stuff to scroll through especially if you have like you know 100 or so columns in here it says 166 so what i'll do is i'll skip over here and what i want to focus in on is related links all right you see down here this add to service catalog that's what you want to click on when the back end like all your columns and stuff are already set up and the reason why is because all you're going to have to do is once you click this you design the form and you move on from there there is a video on the channel it's called how to create a record producer with a couple of clicks or something like that i can't write the exact title but you go check that out it'll show you how to do that second thing is like how to hide the information icon so the reference data and the portal so what do i mean by that that's a great question so a lot of times when we talk about a reference field like the requester right it's coming from the user table there's a little i that appears here and like for location also it's going to location table so maybe we don't want the the user to be able to click in there and adjust the data um so one way we can do that portal wide excuse me kind of skipping around here is to come it out great is to come to our portals right here so we're going to go to underneath service portal we're going to go to portals we'll find the portal this one's called aspen now and then down here in our css variables what you'll do is you're going to put in these i don't know five six lines of code um i'll let you do a screenshot or whatever it is right now hold for a second now what i'm going to do is i'm going to take these out right um one thing i want to mention too these this css variables slot right here is that you don't have to do a portal wide you could do it based like you could do it in the widget if you want to add those lines and then it would have the same effect what i'm going to do now is undo it so that way you can see what this looks like with the the eye or information icons in there and my apologies take a little bit for this to update today so now i refresh this and now pull this down and you know it's always taking like it's taking forever when you see these three dots here kind of lining up um practically just made that portal change uh let's see here so now you'll see the eyes populate so again this is something that if you don't want them to see this stuff those are the lines of code that you would add right there right so if they click on the eye they'll come in here and maybe they'll be able to edit some of the stuff maybe not just depends on the role that they have right but you generally if you want to lock it down that's the way you would do it so what i'm going to do now is i'm going to reinsert those six lines of code or so in here and i'll click save and then we can move on to the next one so the next topic that we're going to talk about is variable defaults and onchange client script is a combination to do dynamic data so the requirement would kind of come from your customers like this that when the screen loads they want to be able to see their information populated in here and then they want the location coming from the user's profile they want the phone number coming from the user's profile and then they want the instagram coming from the user's profile which sounds great so a lot of people what they'll do is they'll go in there and create an onload client script but you really don't have to do that what i like to do is just do the variable defaults so i pulled up the variables here which have those defaults in them and i wanted to show you the default values i think i can do this request or one real quick just looking at it here in that you'll see that out of the box servicenow has basically these functions that say hey go get the user id this one here for the location and maybe i can just scroll through yeah so here's our requester saying hey go get the user id and display it this one here is notice the reference here for location right so we're referring to the location table however here what we're saying is look get the user and then get the location field from the user's profile right so just note that it's getting it from the user's profile and the same thing here with the phone number we'll do phone and all that i know your next question is going to be like hey can we do this with a custom field sure right here you'll see and notice the subtle difference here that we don't have to get display value we have just get value and then i put in you underscore instagram and it's c and the instagram is pulling this information from my profile and then the next one was for the date and time we want to have the current date and time so basically whenever this thing loads it's going to in that date field it's going to have the current date and time so all those all that information is coming from at least these four right here are coming from my profile and this one's just pulling from the system every time this screen loads again it'll come up with the current date and time so then at this point we want to make it dynamic and when i say dynamic we go back to our front-end form before i go to the script sorry i was jumping ahead there let's say uh when i say dynamic when i change the user i want this information here to change we'll notice he doesn't have an instagram in his profile so that changed also and the point of that is sometimes you're going to have forms where people can request on behalf of another person right on load the requester matched what was here right basically the person looking at it but sometimes you'll find they want to have the requester or they want to have it requested for and a requested buy or an open buy and open for whatever they're going to have hours of discussion on how to name it what should display if it's intuitive to use or whatever blah blah blah the main point is that if they ask you to populate it with the person who's looking at this screen that's the way you would do it using the default value later on if we want to change it we're going to create an unchanged client script everything is running off of the aspen requester in this example all right so we have our catalog item here request we have a requester and then if we want to apply it to the target record we can do that too so after it's created and it goes to the back end table it would work there too one other thing to note you might have this selected like desktop it's not going to work in the portal that way you want to have either this one or all selected for this to work so then we have our standard function on change blah blah blah going on here here's one of the money lines right here notice line five we create a variable called rec then we're saying on the form dot not get value but get reference you get the reference of aspen requester right that's the variable name that we care about and then we have this set phone here right notice that we have our function set phone right here and then we have the wreck we need the variable see this little mapping right here you can kind of draw a criss-cross on the mapping to it onto these two and just make sure in the right places because later on you might want to use this and change the name say perfectly fine right there we're going to go ahead set our value we're going to set the phone right so our phone variable to whatever is in the sys user profile for aspen requester so this req req is right here right so we're saying okay whatever's coming from this profile i want the phone to go in the phone slot then with the location variable you want whatever's in the location field in the user's profile and then notice here we have you instagram and our req dot you instagram so those are the three fields that we're setting from the user's profile every time that thing changes moving on let's talk about variable attributes and displaying uh reference data so we already went we already had that customer requirement to get rid of these little eyes here right now then maybe the customer will come to you later and say well look i want to be able to display um the person's phone number and their address because there could be a million jason miller's in here right so if i type in jason miller uh maybe there's maybe one jason miami but maybe there's a couple that appear like jason miller so i want to get the one with the correct phone number and address so we have to bring in uh the information from the sis user table and maybe even they want to be able to look it up via their instagram too so i don't think we have that covered here but maybe i can show you how to do it right now so in order to and we'll focus in on the requester variable so we'll go to our variables um and then we'll come into the variable here we'll notice our variable attributes so these are kind of cool you can also go to servicenow documentation take a look at some of this stuff um this document this page right here you know if you're on from servicenow you're watching it i will say one thing it's kind of confusing the reason i say that is that like it tells you the variable type down here on the third line so you kind of get all excited like ooh loud extensions okay but what can i use that with well attachment so you have to go through all one of these like if i were to do this i would have like columns set up to say okay here are the ones that go with the reference field um so i'd have like you know variable type reference and then i would go on down the line and then if i want to refer to some of these diagrams i would just be like see you know whatever it is diagram one or whatever below um and also like this is searchable one um you'll notice here note um not applicable in service portal so that's one thing to look out for too that's why i don't kind of like this you know the way this document i love the content i just don't like the way it's arranged um so let's take a look at our attributes here so the attribute that we're going to use this ref ac columns right so we already saw we had phone and location in there so now we want to do you instagram and i'm going to add that i'm going to click save it'll take a couple of seconds uh for for this uh to line up also and uh or load up excuse me you can see right here it's still loading and what we'll do is we'll go to the front and now and refresh here and we'll see if at aspen now appears in the drop-down so i can look it up that way too because that might be the most unique identifier of them all or maybe phone number i don't know like i guess some people can have multiple instagrams but changing your phone number man i feel like no one ever does that so let's go here i'm gonna change it to able and then what i'm going to do now is i'm going to change it or i'm going to try to go by aspen now as you can see here bubble pops up right and then it changes everything here so beautiful we could look up that user that way too so just remember that for that go into type specification and then down here all the way at the bottom you're going to see here then you can put in ref ac columns equal and that's just one of the examples there's some other attributes out there i don't want to go too much in depth but i feel like that's the one i most commonly use especially when it's in conjunction with knocking out those information variables excuse me icons within the platform now here's a little trick that i like to to do is call it's called leveraging variable order so you probably understand how the variables are sequenced over this order uh column right here and we kind of put an order via number um you know 10 20 whatever it is 100 just space them apart that way what i like to do is for like the containers especially i don't know why but it seems like i'm always searching for like the container split and the container start and then i also want to figure out like where like the variables are in relation to these two so what i'll do is all the container ones i'll end them with a seven seven seven down here now you're probably saying like look you could probably um you know just type in container or whatever and that'll bring up those four or five whatever that's fine but i need to see the variables also that's kind of like the other ones that are non-containers too just to see how they light up so just like a quick scan like using just you know the order here i can just make the trailing one to seven and it makes a lot easier for me seven seven down there so i like that little trick to use sometimes all right so then how do we filter our variable values now as you know that um there are no real like dependent fields like we have on the back ends um with uh you know our regular table stuff so if we have a category sub category set up like this and you'll notice i did two and you probably thought to yourselves like is this guy drinking too much coffee this morning or what he doesn't need two categories sub cat why is he doing that the reason why is i want to show you two different ways you can set it up which hopefully will help you out so if we go into our variables here um we'll see that we have a bunch and the ones that i wanted to focus in on those four that i talked about the category sub cat so this one and i i don't think they recommend this but i know a lot of people do it they'll try to go straight to this choice table okay fine you want to go to this choice table and try to pull out like six categories for you know this custom table you built or let's say you even had 20 categories for incident or 30 or 40 but you know that choice table has a lot of stuff going on with it i just feel like that the reason why they tell you not to use it is because it's gonna hamper performance but if you do then fine okay so look up our value we're looking up the label and then i created an advanced ref qual here notice we started out with javascript colon and then i'm saying the name is incident so name means the table because on the choice table it has a listed as table but really the um the value is name saying if it equals incident and inactive is false and domain is global and then the element is category then display the stuff right so basically all this stuff has to be met so and that's for the the variable is called category so if we go look out on the front end um it's going to pull all the ones there for incident you know we can we could check if we want to and see if that's true i don't think we have to waste a lot of time doing that though but i think the main point is to show you how the filtering part right because you're more interested about this subcategory you're probably like look dude i know i did that for first part fine you want to do the second part because you know the first part you could probably do with just regular you don't need an advanced rough ball the second one that is my go-to and let me scroll in just a little bit so that way you can see a little better so if now i'm going to say here this one to me has been critical i like to say if it's not empty then and we'll notice we have this in parentheses here so we're doing an if statement if current.variables mean the variable on the form is not empty then we're going to say the dependent value now where's dependent value coming from that's not on the form this is choice table right that's where it's coming from because there's a column or a field however we want to refer to these as on this choice table called dependent value dependent value has to be equal to that category for it to to display now you'll notice here i'm not telling it has to be an incident subcat i'm letting the other filter do all the leveraging of that part right because here i'm saying it has to be incident here all i'm telling it in the if statement is that look the category you only have to do the filtering when um it's basically um not empty so yeah if someone were to go in and try to do the sub cat first is that going to be pretty nah it's probably not going to be pretty because again there's like you know all these sub cats in there and someone might get angry and be like you know why why can't they see all this stuff you know like like i said this isn't a good way to do it right and i think that's the way um they tell you know you shouldn't be doing off this dish choice table notice here when i change it to business rule it clears all this stuff out we only have one for business rule so let's let's take a look at the other way to do it so if we take a look here this is our variable called jm category and now the table that i'm looking at is nazi's choice what i'm looking at is the assignment data lookup table and the category is listed there so notice here i don't have to put any variable attributes in because when we go to this table we'll see that here's our assignment data lookup table you'll see here's dl underscore you and you can create these these custom too like so if you have like your own record producer for a custom table or whatever you can create your own data look up you just have to extend that dl table i believe is the way to i think there's also a video that i had one of my guest stars do on setting up like data lookups so you can go check that out too if you don't know how to set one of these up but look here we have two categories that are business rule one is email one is mac so basically what we're saying is that when business rule is selected on the front end we just want to see email or mac now let's see if that's true so we're going to come down here we're going to select business rule email or mac perfect now how did we get there let's go take a look at our subcategory because that's going to tell us you know what's what's in the secret sauce here so again i have an if statement going on saying look at jm category meaning that other field right is not empty then i want category where's category coming from right here to equal the same thing as the jm category variable right so uh one thing i would recommend is if you're going to be doing a lot of filtering or a lot of stuff on the front end and you're going to have these category subcategory filters i would try to write this somewhere on a piece of paper and memorize it this construct here just remember this though right here this part this is always coming from the from the table so just want to kind of hammer that home okay so now we can go ahead and show you a little trick here too so i think we can use yeah i want to do this one here so like let's say we don't know anything about um creating advanced ref qualifiers and how to do all that stuff if you have a simple one set up what you can do is in this one here this aspen requester is using a simple rough qualifier name is not empty active is true fine if you don't know how to do it just change this from now this is after you save it with these values in there okay so i don't want you to come in here create a couple of filters without saving it and then change to advance and then nothing happens but if we change this to advanced we'll see right here it gives you the rough qualifier right there so all you would have to do is do javascript colon whatever throw that in there and you can use that elsewhere so that's kind of like one of the tricks you can do you could probably do it you know you might be able to do on the back end the key is going to be later on with like your if statements and all that type of stuff that's where it gets complicated with these ref qualifiers and if you were to ask me like what the most complicated part of the platform is for um maybe everyone but especially novices is this rough like doing advanced rough calls i feel like that's the hardest part but that's just my opinion okay so we talked about leveraging variable order um we did that i thought there was one more in here did i do the clvc acronym maybe that's gonna be okay so sorry i'm gonna go ahead and put this in i didn't want that presenter mode yeah that's fine sorry about that i was rearranging slides earlier okay so container and break line container start so i want you to remember that and i think it's actually um better illustrated if i take a it's actually label so sorry about that i'll need to correct that maybe i did and i just forgot to change it but so what we're trying to do here with this acronym is get a good way good methodology you see how this section break right here occurs watch what happens when i change this request urgency to critical which i'm going to do in a little bit see this new section label how it kind of confines to its own section it looks nice like that whenever you want to create new labels um in a new section always think about that acronym so that's that's one thing that always comes into my head is cblc so i mean container and break uh then what is it label then container start so in fact what i'm gonna do is i'm gonna fix that right now so that way we can remember that for later sorry about that okay so yeah that that uh requirement always uh seems to pop up from customers or they'll ask me like well can't you break this out to a new section um yeah that's the way you would do it and a lot of times that's what the deal is with customers they're more concerned with the aesthetics and the appearance of the form rather than the data they're getting out of it so let's talk about some uui policies here to set value i want to talk about one calling thinking backwards and then another one to validate a date and yes this is all being done via ui policy so you can also equate these ui policies to on change client scripts there might be some parallel examples that we could draw from that so our first one that we're going to look at is uh the mandatory fields one which you probably know all novices know there's no conditions we're just gonna plop our uh variables in there and then we're gonna create a just a mandatory um is true condition right there on our ui policy actions um now let's take a look at you know you're probably like i've already seen that before the reason i look the reason i point that is that you're going to see some without any ui policy actions and i'm coming up you're probably going to be like well how does this how does this do that so notice here we have date one before day two we're going to have a kick out and error so let's go over to our record producer here and now let's say if i do day two on september 1st it clears both of them out and then it comes up with that message now you're probably like well i've never seen a ui policy do that before so let's take a look at our construct here right our conditions day two is more than zero hours before date one right that's all it is we're gonna use our script yeah this this tab i feel like is very very underutilized see this run scripts box see when you come in here it's gonna be like that you're gonna check that box and then again with that ui type i was showing you for the change script same thing desktop mobile you probably want to go with all right just to cover yourself and then right here what do we got pretty simple statements g form set value date one so clear it out day two clear it out then we're gonna do a show field message day one day one must be before day two so that's where we got that from now we'll notice here there's an execute if false i'm not going to put anything in that box the reason why is because we'll see here i have this reverse of false is there so i don't really want it doing anything i only want this to occur when this condition is met and that's it i don't care about the reverse of it if the reverse of it happens i want everything to flow normally i don't want any any message to pop up to the user i want them to go about their business and fill out that form so next one is going to be for covet 19. so if the category is covered 19 again no ui policy actions we have a script here all we want to do is change it to critical the request urgency right so g form.set value here's our field excuse me our variable name and then here's what we wanted to put in there out of our choices so let's go test it out in fact i want to reload the form and you know you're always going to have those one-off situations where they're like they're going to give you a list of all these um you know categories or everything i say well for that one right there we want the urgency to go up on the form you know and that is even if you like let the users pick their own urgency because a lot of times um they don't they're like look if you're filling out this form we don't think that it's critical if you have time to fill out this form the only critical ones are the ones that come to us via call meaning the phone so i think it was this category is kova 19 and we'll see if it sets it no it's not that one let's try this one yay so is this one here jam category request urgency is critical watch what else happened see this critical urgency description pops up we're gonna save that for just a second um so that's gonna be our next one so again here's a review of our covet 19 one if you in case you didn't catch that script and again i don't have anything down here in the executive false if it's not kova 19 guess what let them pick their request urgency or whatever it is so for here this is our next one critical urgency i did this one backwards so when i go back to this slide think backwards think in terms of is not mvc so mandatory visible and clear false false true let's go take a look at this so if the requirement comes to me and they say hey jason i want it so that if when it's critical i want the box to pop up at the bottom and i want it to be mandatory what i do is i create one that is the opposite of it so that way i can clear the box meaning the um the item that they wish to appear in case they reverse it and the reason i do that is because there have been several times when i've gotten this and we can take a look at this clear the variable value so here's the construct right we're saying here it's the opposite of what they want right so if they're saying when it is critical we want it to appear want to be mandatory um then we would set it up as it is not whatever they want and then we're going to say mandatory is false visible is false and then clear the variable value the reason why i'm clearing it and on load is not going to matter right when you first load up your page who cares but like let's say they put in jm and then later they changed their mind well i don't want that urgency description to go through to the record producer what i want is for it to clear out which it just did so if we run through that again i'm just going to change it to critical so on load nothing's going to be in there no big deal then we're going to change it to critical and we're going to see what happens when it's critical that box will pop up at that point i'm going to fill it in change it back to standard so here we go critical this pops up now let's just pretend that this was some sort of reference to either an individual or a group that was an approver and then this box was something a little bit different i had that scenario too that's why i would have it clear out is because maybe there's another box that was supposed to pop up to determine the approver too and i think i had one that had like seven or so and it could only be one of those seven so i had to have it clear out just in case they changed their minds like that so that way when they go back in there's nothing there and going back to that example i was using that real life um experience that i had or a customer requirement um it could have fired off two approvals if i didn't have it clear that first one so that's what i'm saving myself from there and i think we covered all three of them so moving on last thing i want to talk about is leveraging the record producer script instead of the business rules so one thing i feel like a lot of individuals probably neglect is right here is a script and we'll notice here we have uh we're setting the state to open right or the integer value because state is an integer and then we're setting the contact type service portal these aren't things that we want the user to do when they're filling out the form right so that's why we're doing it here in the script so when they hit submit it's automatically going to open up the record it's her the state is going to be open the contact type will be service portal sometimes people will try to do this via business rule i just don't feel like um that's something you want to do like stacking up all these different business rules because later on maybe you don't condition them properly or whatever this ensures that it's coming from the record producer when you're doing the script in here because you could have multiple methods for opening up these aspen request records so there could be phone and email and stuff like that so what i'm going to do is i'm just going to send one of these through i don't know do none actually let's change this one to business rule we'll change this to business rule just to satisfy the mandatory requirements i'm going to hit submit and it's going to come up with a number here and then i'm going to go to my requests all right and let's just see if it opened up correctly so we'll come in here and i thought it said 111. but yeah it looks like contact type is service portal beautiful and state is open so it set it exactly the way we want to and also the user wasn't tasked with doing that which was pretty awesome so just to review today you know here's a couple of our tips tips tricks and scripts try saying that 100 times that we went over prepare our table first make sure our back end is good to go hide that information icon if we don't want our users messing around with those those fields that are in the reference data don't forget that default and on change client script combo that can help us out instead of onload client scripts we have a variable attributes that we talked about don't forget to leverage that variable order um that was one of our tricks and that advanced ref qualifier flipping it back and forth once you have it safe from simple to advance will give us a rough qualifier don't forget that cblc for the section breaks in case you need to create a new section uh and then we have our ui policies and some of these actually acted like unchanged client scripts which was kind of cool and then we have our record producer script which we just talked about if you like what you saw go ahead and click like please my name is jason miller founder of aspen now solutions and we've just unlocked the power service now

View original source

https://www.youtube.com/watch?v=6guuYMnQFKU