NOWCommunity Live Stream - Topical Deep Dive - Loaner Request App - Part 2
[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 i'm a senior developer evangelist and i am here to bring you the ideas the thought process the journey of discovery that goes on behind the answers to the community these episodes are inspired by your questions your issues that you post to the community and then i bring them forth into a colorful commentary topic like today this is june 8th 2020 and i am doing a follow-up from the episode on june 4th so if you haven't seen that you might want to go back and watch that episode i built out an application and i did that rather quickly and intentionally because people were asking me how did you build this or how would you build this if you were going to build it in 2020 so that was the point of that i know i went rather quickly and in fact i ran out of time so i'm going to fill in some of the gaps i'm going to continue that journey today with some of the components that i didn't get to build in on thursday there was quite a bit i practiced it a couple of times and i know it fit into that time i just don't know where the time went so that's what this episode is all about thank you for joining me we will be doing a technical deep dive and i'm looking at the comments people are jumping in i did rearrange a few things on the studio so it may be a little touch and go here for a while but i appreciate you you're sticking with me looks like the broadcast is working the comments are coming in thank you everybody once again for joining me i mean so much that you are part of this we have a number of people watching commenting we do this live on youtube let me see if i can get that right there the buttons are still where they should be so i shouldn't have a problem with that youtube url right there you can see that subscribe like comment notifications all that good stuff let other people know it's there this will be posted to the servicenow community this is called the community live stream for a reason it's part of the servicenow community which is what you see right behind me so youtube community community can be found at community.servicenow.com if you're looking there for your answers if you've got some real questions that go beyond hey how are you doing what's the you know commenter commentary on what i'm doing in this episode please post it there tens hundreds of thousands of experts are in there we're waiting to help you with your questions and answers i post in there and i get wonderful answers as well so it's a it's a give and take it's not just a one-way street that hey all you got to do is be able to get information out of there all right that we also do this on twitch at twitch.tv now community those episodes are up for a couple of weeks so look for those there this is the final week of our knowledge experience knowledge digital experience knowledge.servicenow.com is where you can go however a lot of the content is going to live on for a few weeks months i'm not sure exactly how long but if you missed a session say in week two you can go back to the on demand and catch that a lot of the workshops and labs have been migrated to now learning for a limited time so if you want to go back this is the time to go get it obviously this is the last week of live content or simulive as we call it it was recorded say last week or the week before now we'll have it there with people in the chat you can engage the same way you've been doing for the last five weeks but the six week journey of knowledge is almost over and thank you very much for being a part of that thank you for participating and i hope you got a lot out of it as all of us did so go over there for all of that goodness that information the the the hack snacks are still there from creatorcon in week two the the keynote from last week from bill mcdermott and cj desai all of that is still there check it out it's on demand or you can schedule up for this week so i encourage you to go and look at that we do have our upcoming tech now webinar on june 23rd sign up at the bitly link you see there bitly slash tn76 reg michael slobodnik will be coming at us with flow designer and integration hub the updates we've made in the last 18 months i'm not sure where that title came from it's not the one i wrote but that's okay you get the idea we will be doing a little bit of scripting in this so if you want to learn more about javascript you can go to the bitly link there i've got a whole series that will get you more comfortable you may be new to the now platform you may be an admin transitioning into developer role you may just be curious and want to learn more about scripting it's all there in that series preparing you for the servicenow scripting course which could lead you to the application developer course which could lead you down a whole new road there's also free learning plans over at the developer site developer.servicenow.com where you can get free learning plans free servicenow instance for your very own to play with and reset and blow up and do whatever you want with it and reset it and start over again one of the other things you'll find over there is the meetups at meetup.com pro it's under the event so if you go to connect and events you'll see a list of them meetups are starting to spin up again now that knowledge is coming to conclusion there's some for june there's some for july already scheduled take a look there's tens of thousands of people worldwide checking out these chapters around the globe that's a bit redundant worldwide and around the globe i get it but check those out great people to meet up with even if it's not in your immediate vicinity a lot of them are virtual now so you can participate like i did in stockholm a few weeks ago or atlanta a couple weeks before that so really looking forward to meeting some of you and getting on those when the calendar and clock line up so that's what we've got there what's more a little bit of script i mentioned we will be doing some scripting today you can find that all on github i will post that immediately after the camera stop rolling it's going to be in a dated folder 2020-06-08 year month day format so they sort nice and accordingly there's also scripts from the previous episode in the june 4th folder so look for those there over at bitly sn cls i did have somebody write me on linkedin and say i can't get to this it seems to be gone not seeing that the short link and the long link actually still worked i don't know what's going on with with that particular situation i said if you're still having problems let me know they said thank you so i assume it's fixed i don't know what was what was the deal good morning sandeep ravi shavudu carolyn a lot of a lot of classic names in here we've been doing this for about two and a half years and uh good to see a lot of my old friends jumping in and joining let us go to the site where we were last week so let me catch you up on what we did we built out the loaner request application or major components of it so there's probably six flows i could have done in flow designer i did two to show you some of the capabilities of that i know i went a little quickly and some people commented on that on the youtube video saying hey you know you could have made a series out of this that was not the intent but i'm putting on a part two for this because there were some things i wanted to get in there i apologize for going fast but the intent was not to go deep into flow or deep into you know ui actions those are future episodes the idea was to show you how i built this application so that you can build similar applications or maybe the same one for your very own in your organization so you can take those skills that that that outline if you will to build applications and know what the capabilities were if you want to know more if you want to go you spend some serious time on each of these topics then i highly recommend our application developer course over at now learning you can get an instructor that goes through slide by slide and explains and hands-on lab guides where you will build these things it is the same application it's the loaner request application that you will build so you'll have a familiarity with it you could even take this video and and play around with some of those things before you got to the course so that you could become more familiar and comfortable with those concepts with those capabilities and do better in the course i don't know or do the other way around take the course and then come back and watch this video and go oh yeah did that did that oh there's something we didn't do let's go play with that a little bit more so i offer that up as not just a a promotional thing but it is the next logical step if you want to be building applications please go take the the i think it's a three-day course virtually led of course at this point i don't think we're doing an instructor-led courses but take the course that's where you'll find all the detailed great information spend the time ask the questions and get into that so there that's my promotion for our wonderful training department who has built that course out and kept it up to date unlike i have done with the actual real loaner request they've they've put flow in there and all that good stuff so loan request application tracking loaner assets temporary assets that you get we built a service catalog we built some reports we built a couple of flows did a little scripting to make the reference qualifier a little smarter so when you pick a laptop it says is this available in this area at this time with this type we've got that down what i didn't get to do and here's my really cheesy outline i'm going to finish the mobile piece with ui styles and put a smart button on there really want to show you what that is because that hits home of what the mobile capabilities are we saw how we could dial the phone with the uh with the caller's number did we do that now i have to go check no that's what we'll be doing with the smart button okay that's that's why i wanted to tie that in because it is a native mobile application unlike just putting a service portal page up you can actually do some of the stuff with the native mobile device so let's go do that i am in studio and under mobile studio you see here i've got my applet i've got my applet launchers my data items i want to create a ui style so i'm going to pull this out put that back it comes up with the new list i'm kind of digging this new zoom thing now that i figured it out i hope that's helpful for you because it really it works well on videos so why not do it live now that i can okay i'm going to call this overdue items now if you watched a long thursday you know what the expression is going to be to determine an overdue item we're going to look at the loaner request table loaner request and i am going to pick on the state field that's where this is extended from task so i've got a few extra fields in here and i'm going to turn the background red the text a little redder i think it's a pink and a red something like that this is the style i'm going to apply to the state field if it matches this condition so i'm going to say state is you remember this this expression how do you determine if something is overdue well it's checked out and it should have been back before now so i will say the actual end is at or before this is one where we have the long drawn out list rather than the little nice calendar picker widget and current minute is near the bottom i submit that now that i've defined the style and you can do other styles if you want make the number red or the short description green the color purple whatever field you want to style you can do this way so i've defined one style for the state field i'm going to go a little slower today and explain because i have some extra time feel good about that now let's go back to our applet which i simply called active it was the active loaner request and i happen to have my phone screen available here oh look we're live on twitch and youtube happy days okay so let's unlock that phone here is my screen you've seen this before it's a simple list i do have my swipe thing for checking items in and out or checking them in only if they're checked out notice that there's no swipe on this third one down right here nothing happening on that one no swipey i'm going left i'm going right nothing's happening okay so back to the ui style what i want i should have said what i want what i want is this guy up here checked out red checked out not red because this one was is not due back that doesn't look like my style huh my style should have an actual start on there but yet i'm not seeing it it should be oh you know why something happened to my pattern that's not my pattern let's go fix this my pattern should be over here i don't need an avatar for the actual checked out date i want two pieces of data here but when you change the pattern which is just a pre layout so you don't have to worry about getting pixel perfect on this it says by the way i'm going to blow away all your fields oh boo hoo we can build that back up real fast state number item it was item then item type then actual start and open buy okay now it doesn't look so funny i remember actual start had this cool time date picker thing so let's save that makes me wonder if my details my form layout was fixed let's go back to the phone go back refresh gotta refresh when you make changes in studio you've got to go back and refresh and still not there this may be what i suspected i didn't want to happen okay let's go find out i'm going to close that applet i'm really hoping this isn't true no i don't type actual start it's there why didn't it refresh okay make sure i'm on the right instance go back here refresh one more time active well that layout isn't any fun but that's okay because the state field is still on there not sure why it's not happening down here in pre-orlando if you and if you pick what was it called a pattern type one the older patterns you will actually see which ones are applied you'll get the list collector the side by side some people call it a slush bucket trying to break myself of that habit down here i map ui styles this is the new orlando style two-way takes you to this record which is full of lovely json stuff but down here you see ui styles so i'm going to pick which ui style i want and it says overdue item the fact that it didn't update the style on my phone does not leave me optimistic that it's going to respect my field mapping style and it brings you to this crazy screen which i don't know why okay just for sanity's sake let's save that one more time still the right pattern go to the mobile screen see what's happening and refresh you know what just for jollies i'm going to log out and log back in sometimes that's a little more aggressive than just doing that so i'm going to log into my instance and i think that was the right amount nope try that again one two three four five six have two very similar passwords active there we are okay see now it's got the date on there and for whatever reason this top one is not field styled right so let's go back into the map ui styles maybe it didn't save it and it did not craziness this is the fun of doing this live i'm not sure what oh i click selector overdue item lock it down update it save it refresh it i don't think it'll refresh for me oh it did okay i didn't have to go all the way back to the main screen and there's my flag that says hey this is an overdue item yeah it's checked out but it's overdue so i don't need another status or something cluttering up the screen i've got a nice visual indicator that this is overdue so that was one of the things i wanted to show you in mobile the other is when we drill into now notice that i drilled into the record but this one is not i would have to do the same form i won't have the right style go down here map the ui style same way same kind of thing what i want to do is when i drill into this record see how i have a nice phone number here i'd like to have an icon there that i can just click the icon make it dial okay this is a phone it's actually a real mobile phone that likes to turn sideways when i set it down sorry about that and i would like it to have an icon that i could call because that's what mobile apps do let me show you how that's put together that's called a smart button so under functions i have smart buttons and there are several of them that are already no they're not i'm sorry i was looking at the other actions there are not several of them this is new so i will create new smart button these are very easy and very fast call this call loner requester whatever and it's going to be a type phone i can put in here call the person at the indicated phone number all right be good to yourself put in descriptions i can either have this as a context or global i'm going to put this in the record as my context my table will be you guessed it the loaner request table is where i'm going to be looking for those records and my field is going to be not on the loaner request but i need to drill into opened buy because that business phone belonged to the caller okay so i picked the business phone and if i do cellular it wants this sms field which i have no idea what it's for i'm not sending him a text message although i could i'm going to just say pretend it's a landline and that all goes away not a problem when would you like this icon to show up well i'd like to show up as long as there's something in the business phone field so let's go to opened by business phone is not empty works for me if you don't have a phone number i don't want to see this icon it won't mean anything because it's going to be a blank display anyway what good would be a blank field with an icon that does something save that and i then go over to my applet which is back here and underneath the form screen i have body excuse me i have this functions right there and function says you can place functions in a couple of places oops this isn't the right place but i want to show this to you anyway i want to go to the body and down here i have field functions okay i always get where my functions are messed up because you've got a couple of places you can put functions i have the list screen functions which i can put something at the top in the little dotted menu i can do my swipe functions that's where i did my check-in for anything that's checked out and i can also go over to the form and i have functions on the form i can put something on the top of the form that's not necessarily on the top of the list like close this thing maybe it's not a swipe action it's a top i can also do footer functions and let's go to the body and in the body is where i can say i want something to act on a specific specific field that's on the form or i can put this footer function down there that is a big button that says do you want to close this do you want to call the person whatever so i want to put a field function which is right here on the business phone field it knows because that's the pattern i used and that's the fields i put on there it knows there are only two fields on there so i'm going to attach this smart button little easier than doing the top functions of the swipe function because there's not that middle action so i define the function and here's where i'm putting it call the loaner request phone and save that because we made a change go back to my mobile app i don't know if i could just swipe down on this one but let's go here swipe down i'm on my list open it up and look kids i have a little mobile icon and if you want to call that number you're going to get the time and temperature in appleton wisconsin but there's no real point it's now connected to the native capabilities on my phone says how would you like to do this i'd like to call with the phone and there we go okay i've just connected my phone app to my servicenow mobile app i can call this person go hey this laptop was due back in march did you lose it did you break it should we do something about that and away we go okay so that's that's the mobile capabilities i wanted to show you what was next oh some of the other cool logic uh let's put the process flow formatter in some of you may have seen this may not have known how it got there some of you may even looked at it a little bit process flow formatter came out interesting story i'm gonna go back in the way back machine knowledge 10 there was a contest called the innovation of the year award some of you may have heard i won with the loner request app however appropriate today and the one i forget if it was second place or third place had this little chevron like subway map across the top of their form that's what they came out with that eventually became the process flow formatter plugin so i believe it's activated by default now but if it's not on your instance it's not on your instance you can go to your plugins under system definition plugins and look for this so it's as old as the laptop request app only this is officially servicenow supported it's not a user a customer contributed thing if i look for process flow i have the process flow formatter it's already installed it didn't used to be i think long about eureka or geneva or something it started turning on by default for all upgrades and new instances so we'll go with that how do you use it well let me show you i have in my loaner request app let's look at one of these requests a series of states requested um i can't remember what they are show choice list oh this is going to get ugly we want just the ones that are let's let's do my own choice list table is x orb loaner request element is state there we go we have requested reserved prep ready to pick up checked out post completing cancelled okay now i submit that complete and cancelled are effectively done you're at the end of the map it's not going to do anything else okay but these other ones it's a linear process you don't go from i'm i'm it's been checked in i'm doing the post uh deployment tasks and suddenly it's reserved again that's not the way it goes okay this is a pretty linear process in which case this visualization is nice so i take these 10 11 12 13 14 15 3 and 4 and i'm going to go to the process flow formatter which is under system ui process flow take that and create a new entry and it is going to say i want this on the loaner request the name is a friendly description but i often associate it to the state so requested the label is what shows up on the map requested the order is linear 100 200 300 you'd be you put in what do you want i generally do the hundreds so that if i come back and say oh i need something between requested and prep it doesn't become a problem i can put it at 150 or 250 or whatever it is so state this is the condition where do i want this to appear is requested not too difficult you could put an additional description i believe this is the tool tip but i don't know requested but not yet confirmed we'll put that i haven't played with that box in a long time so let's find out when you do that it does a couple of things it creates the formatter and it um i thought there was another message up here that said i'm i'm going to create something else for you but by building one of those states it also creates the formatter now what you get if you go back to it's not going to be all that impressive but i'll show you if you go back to loaner requests all and you can do this either with configure form design or form layout i'm going to show you form design first form design we'll have this under the fields and way down here in the formatter section is now a process flow here's the rub okay i haven't done this in a while and i don't know if i'm gonna be very notice this is a two column layout and if i put this up at the top it didn't really do that great of a job up here okay that's only one column how do you get a two column well i can put in another column here this is where it gets a little dicey i haven't done this in a while there used to be a bug with form designer if you messed around with this first section this is called section zero because it's an array zero one two three if you did anything with section zero if you moved it if you retitled it it would throw the whole thing for a problem don't know if that's been fixed what do you say we find out because i i was just doing some form layout this weekend yeah i kind of do that on the weekends and it didn't go so well i mean i wasn't brave enough to try it sorry so now we're going to find out if this has been fixed i want a one section layout up above there notice it automatically transfers the name i'm hoping this works i'm hoping this works i'm hoping this works because we want our formatter full width let's save that i feel like i'm skating on really thin ice right now and refresh and it worked okay doesn't look that impressive it just says requested because that's all we have for the process okay let's go back to the oops didn't realize i tapped that twice let's go back to the process flow formatter process flow we will create another one on loaner request table we'll call this reserved let's just fill these in real quickly copy paste 200 state is reserved okay save you know what else i didn't check i didn't check if where that description went if that was a tool tip we'll do the next one prep prep 300 state is prep insert stay hope i don't go too fast uh next one would be ready for pickup ready for pickup done this a few times over the last 10 years kind of remember these states 400 this is just the order ready for pickup insert and stay checked out checked out i'm ready to check out and checked out insert and stay then it's in post oops post 600 post now the last one i mentioned those two were very very similar okay canceled and complete i don't want to create two of them side by side it's going to look funny it's really done okay so i'm going to call that complete complete and for the condition really all i need is active is false so think about the different fields you've got and how you can take advantage of them rather than putting an or condition in here because you may come up with another closed state or another clustering and you really don't want to come back to your formatter and go why isn't it working oh i got to put in another condition this is taking care of all those done closed conditions that you've got insert one last one let's go back to our loaner request take a look this one is currently in checked out so we should see it's marched here it's underneath checked out and the check boxes are checked somebody had asked me is there a way to skip the check boxes i forgot what they said look in the community there may be a post on you know if you skipped over a particular step like approval it might work i don't know it i don't remember what the solution was out of the box we don't have a way to do that i wish we did to say you know when when do you skip but then the rules get a little crazy or you'd have to have some way to inject these events or states or something to say i did this one and later on you say i did this one so again this is meant for linear processes we go there there it is wonderful ui ux experience you can now glance at where you are in relation to the other stuff if i look at one that is complete and i thought i had one up here there's one it will say boom complete let's go to my ui action that cancels something and if i cancel it's going to put it right into the state that we built that on thursday remember canceled and that jumps to complete as well because it's got the active this false true activist false flag in there so making some great progress what was the next thing oh one of my favorites the due date validation we did absolutely nothing in our record producer so if we went to service catalog and decided to put in dates in our loaner request that says hey i want to reserve this from june 27th which is in a few weeks to june 1st this goes yeah fine la la la it's not doing any validation checking here or in the other form so i would like to show you a couple of things to do that i'm going to need vs code my old friend and open up the scripts that i will show you so let's do file open try not to sneeze get my scripts for today and i have a client script on the record producer so i'm going to copy that i will explain that to you in just a second what that's going to do is when you submit not on change you could build these on change but then you're going to need two of them that look against each other and it could get a little crazy when you have blank values i'd rather stop and go no wait stop you didn't do this now let's try this out on submit collapse this for just a second close the little file explorer so we can see the whole thing it says your start date value is going to be a new date object i'm using date from uh straight up javascript this isn't magical it's not glide date times not anything and i'm going to pass it the value of the work start field which is what we call actual start and actual date on the labels then i'm going to also get the value of the end date and now i need those three pieces to figure out where in relationship we are so if the start date is before today says the start date can't you can't reserve something starting last week okay that's not the way it works you re make reservations in the future if the end date is before the start date notice i don't have to check the end date before today because all it has to be is after the start date and if the start date is after today implicitly the end date is after today so you can't lose also notice these messages okay i'm doing a get message in the client script to do my language translation so my alert just doesn't say some raw text i'm planning ahead for future translations if the end date is before the start date no you can't do that either so let's take that script i'm going to go to my record producer in studio form designer record producer and it's going to be under service catalog right down here under record producers loaner request pop that back up and we built this out very quickly from within studio on the table we did this create service catalog down here i have catalog client scripts because the record producer is a piece of the service catalog it's very much like a catalog item but it doesn't create a request a request item it just creates a record let's create that new script this is going to be validate dates applies to catalog item we'll do this for all and this is going to be an on submit and here is that script that we just described not sure what it's complaining about irregular white spaces fine how do you feel now regular white space not allowed well you know what maybe the tab oh there's a tab in here oop all right i'm the kind of guy who likes to align my equal signs and apparently there's some tabs in here there when i have a whole series of them lined up i think it makes it a little more readable i don't know about you but that's my style let's go and check this out i have not defined what those messages are i have two messages in here loaner error start before today loaner air end before today show you where i'm going to define those in just a minute let's go back to our loaner request reload this which we can do right here loaner request is that client script has to be loaded on form load come on and i say i want to reserve it from the first you know what let's make this really terrible from the third so the start date is in the past and the end date is before the start date i'm going to hit both conditions just to mess with this thing i want a laptop from chicago submit and it says loner error start before today that's good we're getting the right condition and say fine fine fine i'll make it start next monday get rid of that one and it says loaner end before start okay you got me putting it this week isn't going to fix it because the end will still be before the start just a little nice data validation wasn't a whole lot of script it's just a couple of date comparisons right of course those of you who have done date comparisons know how much fun that really isn't jay says so when you added the formatter to the forum did it in fact make a new section no it didn't make the new section i had to go make the section to put the formatter in i could have put that formatter at the bottom i could have put it in a you know tab could have put it anywhere i wanted it i feel it looks best and standard practice is to put it at the top so let's fix this so it's from the 15th to the 19th and it submits because i passed the validations okay what about those messages chuck thanks i'm glad you asked well i have to go get what they actually work no i don't it's in vs code in studio i create a new application file and under properties of all places i don't know why it's under message if you don't like it you just type in mess m-e-s-s and it'll come up the key was that string if i were to put in get message and the string here's i'm going to preach a little bit about translations again localization internationalization whatever you want to call it if i were to put the text message right into this client script and say start date is before today it will look great in english it will work fine and someone's going to say i need that in french i have nothing with which to base that translation off of except somewhere in my app it says this text true i could use the code search and go find it and then figure out what the translation is that would be my key and if it doesn't find a key it will use whatever text you put in as you just saw it's using this big ugly underscore thing which is why i put the big ugly underscore thing in it and so i can say i haven't translated this yet by taking this key and making it my default value i know a i didn't translate it but i also it forces me to put in a record that now when someone says i need it in french i can export all my existing records they translate that i'm not hunting around for missing things they shouldn't be missing at this point because the developer will go oh i need to put that in okay warning start date cannot be in the past there you go i created one of them there's a second step for client scripts that you must know about let's take the second one do that and date can't be before start create another mess create mass it's kind of fun [Laughter] how often do you get to create a mess okay warning end date cannot be before start now i could let it go at this point and have a fully functioning catalog producer i don't think i can get it from there maybe yeah okay i don't know history saved record producers if i said date in the past and date in the past also and laptop and chicago and say this it will go fetch that but it had to do it at run time not at load time that's not as efficient as what you could do in a catalog item i think it's in the script itself let me look i got if it's in the item or the script i go and look at my catalog client scripts there is or used to be huh maybe it's in the record producer where'd it go there was a messages file maybe i'm thinking about catalog items create catalog item i just want to see where that field went should be on record producers too there is a field called messages that says when you load this and you get all your javascript and your html and your css also load the messages it's a push rather than a round trip we all know pushes and round trips are more a meta meta meta process no picture no pricing no portal settings no oh that's disappointing where did it go huh okay i guess best practice isn't to use the messages field anymore that's a bit concerning because we don't put it on the form people aren't going to follow best practices are they let me just make sure and see if it's there configure forum layout let's be really adamant about this uh i don't even see the field anymore did i miss it should be there when it commits it let me check maybe it was on the client script and i missed it there configure form layout i thought it was on the script itself oops not that sorry configure form layout messages it should be on the script it is not i am bummed okay that's not what i wanted go back go back go back never mind we'll just reopen that client script okay under service catalog client script validate dates bring it back it's not here it's not on by default okay i highly recommend you turn this on let's do that now configure form layout it says you can't you're not in the global you want to edit here sure edit this section in global i definitely do but i don't want it to be captured with my app my i'm going to put that right up here above the script script save that now i have this messages all you need to do now is copy and paste and it will say i will fetch these on the server side and push them rather than going to get them during runtime okay it's now officially a hidden secret apparently and it will save that for me okay same net effect when you go to the record producer and you run it it will see a message but you will see a message and you'll be able to sleep better at night knowing you're doing a push when the form is loaded rather than a fetch when the message is needed okay that's what it comes down to unless someone's cleaned something up behind the scenes that i don't know about let's also do where's my crummy notes i talked about localization so that's all business rule business rule business rule business rule there is a business rule to also validate the date because that client script's only going to do you wonders when the person enters this so let's take a look at what that business rule might look like when we are updating or creating the record so let's go and create a business rule which you can also find our server server development first option and validate validate dates on the loaner request table that's why i do the show because some of this stuff just isn't documented or isn't documented anymore you used to be in the technical best practices don't know if that still is but it's a little harder if the messages field isn't there okay before we do any inserts or updates on this form so we want to do both we want to validate the dates the yes code we're partially copied that was good so as long as the work start is not empty and the work date is not empty i don't use dot nil too much anymore this is a very very old piece of code and i probably should put in and one of these changes because you really don't need to be running this business rule every single time so in current dot work start here one of these changes let's put that in parentheses because we want to check either of these changes or current dot work and changes i will put that back in my file for repo later if it changes and it's not empty because they may take a date out i don't know why you would do that but i think it's a mandatory field anyway good luck with that you figure out the logic what do we want to do well we want to do something similar we did in the client script only instead of using the native javascript date let's again put that away so we can see the whole thing i'm going to get the numeric value this time i am going to use glide date time it's a server-side function as opposed to using the client-side which doesn't have a glide daytime you use does stuff youtube is not receiving a video to maintain smooth streaming sorry about that if you uh why use the coded condition versus using the condition builder ah good question you could you could i would not recommend using both it gets a little harder to debug but you could put in here actual start is not empty i have done both in fact i recommend when you can go scriptless go scriptless i am doing this purely from a legacy standpoint of this is what i built 10 years ago and it hasn't changed much so the condition hasn't changed so back to our script get the numeric get numeric value lets me compare two numbers i feel more confident comparing two numbers than i do compared to strings even if the strings are year month day hour minute seconds as strings they should sort and you could do greater than or equal on javascript strings as numbers i feel a whole lot more confident doing what you see on line six here to do comparisons okay and let's compare let's get that paste that in here line it up nicely save it done let's go test it we have a few minutes left so let's go to loaner request number three which i think i cancelled but nope still requested if i did not change this and suddenly i said hello in here my business rule should not bark at me about dates being in the past well those dates aren't in the past let's put a date in the past and save okay and we can adjust this one we may need to modify our logic a little more i'm just checking for the reverse dates apparently that's not the best logic save and i also take advantage of this message which puts it under here puts it there says hey you can't do this you can't submit it the end date can't be before the start date which is exactly what we were checking here right all we did is check this if we wanted to check the current date and make sure that things are in the future you know what i'm going to leave that to you ooh challenge exercise add the extra code you're going to need a new glide date time for now you need the numeric value which you can see how to do that in the script and then you can make one more comparison use the client script as a clue as to you only need one more comparison you don't need two or three so there's your challenge exercise with that that's what i wanted to show you that kind of went in there get a little more logic a little more error checking i'm going to give you back a few minutes left in your hour hit that and thank you again for joining me look forward to talking to you on thursday where i share a lessons learned so i'll have the blue shirt on lessons learned is stuff i learned the hard way that i should have a scar on my forehead from banging my head against the wall something that i can show you in a few minutes that took me a few hours going why doesn't this work what's going on how do we do this and then of course turn it into content for you so more fun with javascript objects that i invite you to join me thursday 2 p.m utc whatever that is in your neighborhood it's 7 a.m here on the arizona west coast and 10 a.m thursday june 11th on the east coast till then take care have fun learn something share it and i will see you next time see if this works today still working on the soundboard thank you very much take care bye now you
https://www.youtube.com/watch?v=6dImB2lmMBA