NOWCommunity Live Stream - Behind the Answers - Approval reminders
[Music] good morning good afternoon good evening wherever you are and wherever you are welcome to the community live stream my name is chuck tomasi from servicenow i'm a senior developer evangelist and i am happy to be here this is thursday july 16 2020 and our topic today is about approval reminders this is one of the most common requests i have seen on the community people send out approvals for a laptop or a change request or whatever and it just sits there and somebody says hey i never got the email or where should i go i don't see it on my dashboard and unless they regularly visit you've got a beautiful portal with a badge that says you have three outstanding approvals they might be right they may not have seen it so there are ways to help them once they're there but there's also a way to send out nag reminders i discovered this very early on as a customer and implemented this in script i'll show you a couple of ways we can do that but let's get started as people are rolling in good morning swap nail john allen rahul tanashree everybody's joining in on youtube which you can do right there at the link do what you do on youtube you know share and like and subscribe turn on notifications get those when you're ready i also uh put this out the day before typically the day before on youtube excuse me linkedin i'll post that it's coming and what the topic is so you can watch and bookmark and set your calendars up for that mondays and thursdays at 2 pm utc so you do the math whatever time zone that is for you makes sense to me we also do this on twitch over at twitch.tv now community just in case youtube isn't behaving which it seems to be behaving today thank you very much internet deities for blessing me with the ability to speak to you and i probably just cursed it right there right it's murphy's law there are so many things that happen around here i want to encourage you to go over to the developer site at developer.servicenow.com get yourself a free personal developer instance that's what it's all about because we are only a couple weeks away from oh i wish i had a drumroll sound effect here the paris release early access july 23rd still scheduled for the 23rd so i'll be upgrading my instance right away as soon as possible and starting to explore those paris features right along with you and then we can start talking about paris things on this show as well but we'll get the bulk of that information if you stay tuned we get the bulk of that information over on our tech now webinar for the developers shh don't share the secret this is only for developers okay so if you're part of the developer program i suspect you're watching this and you're also registering for that webinar right now go over to bitly slash tn77reg and get that good morning to jonah and chn wow shane is out there andy everybody's jumping in thank you very much for joining let's go back to i wish i had a way to do this easily i need one button that does this and this and this there we go three year buttons i can make a macro to do that the community over at community.servicenow.com is where i pull a lot of my inspiration spent a couple of hours there yesterday very good stuff lots of smart people hundreds of thousands so if you've got a question that goes beyond approval reminders which is our topic today don't put it in the youtube chat because i may not see it and other people it's going to be very hard to find later on that's not what youtube chat is good at youtube chat is good at let's interact let's have a discussion let's do this live on the topic we're on however if you've got another question or another topic and you want to know something the community community.servicenow.com is the place to go post it in the appropriate place if it's a developer question maybe it's around flow designer or scripting goes in the developer community there's little sub forums in there that you can use if it's around performance and analytics you put it in the reporting and performance and analytics section so that you get the right audience if you've got item questions there's a place for that if you've got questions about security there's a place for that there's a whole bunch of them if you go over onto this left-hand menu scroll to the bottom and say all forums find the one that's right for you there's even a place where you can leave feedback about the community it's called member feedback so if you've got an idea about the platform software and you want to talk to one of our get the ear or i in this case of one of our product managers the idea portal check and see if somebody's already posted and upvote it if they haven't you post something there community is a wonderful place if you are an expert and you've been around for a while and you want to share an idea post a blog content great stuff or make a video gee that sounds like fun i should do that someday okay carolyn good to see everybody that's joining in let's continue on i also want to remind you that there are developer meetups going on all over the place still and i if i'm not mistaken there's one next week in boston see if my memory is working there's a minneapolis one coming up too minneapolis is on the 30th and boston is on the 20th so monday the 20th if you're in the boston area or you're around a time zone that kind of works with that maybe i'll see you there so meetup.com is the place you want to go you can also get that through the developer portal just by going into the connect and it will show the meetups there as well so like-minded people talking about servicenow developer stuff i try to join as many as possible the one in milano probably not gonna make it it's not at a real good time for me and uh my italian is non-existent people still joining in thank you for joining me we're just finishing up the pre-roll i there i will be showing some javascript today but i won't be writing a whole lot so i don't expect there will be a whole lot of stuff in the github repo but if you want to learn more about javascript maybe you you you're an admin looking to become a developer you're a developer from another platform whatever it is i invite you to go check out this video series that i created it's been getting some wonderful reviews great comments and i'm very happy to be able to bring that to you the if i do happen to write any script it will be in the github repo that you see there bitly slash sn-cls and you can find it in a dated folder 2020-07-16 would be today's folder and there'll be a direct link again if it's in there you'll see links in the description on youtube links in the community post the community post we'll have links to all the stuff we talked about today documents and all that good stuff so all that is wrapped up and ready to go uh let's continue on let's get started so today's message comes to us from a viewer community member says how do i do approval reminders again very common uh situation i did this years ago as a customer in a couple of capacities one was to do approval reminders because i recognized the same thing people were getting approvals and they would just sit there and a month would go by and some would say where's my laptop how come i don't have access to this account oh it's pending the manager approval manager didn't know it so there we want this nag reminder actually kind of surprised this isn't built into the baseline platform ready to go with with approvals anyway but we can build this very quickly it's not a problem i want to explain the background and the history so not just show you here's a flow designer go uh if you want you could fast forward ahead till you start seeing me build on flow designer unless you're watching live then you have to stick with me on this one okay so way back in the dark ages we used to do this thing called schedule jobs let me bring up studio and this is what i did for my loaner request app because i was loaning out items and people wouldn't return them so i needed a reminder to say hey it's overdue hey it's overdue hey it's overdue and put this into a scheduled job and this is very very similar to what we would do with a an approval reminder but instead of going through a list of overdue requests we'd go through the list of approvals and say how many of these approvals let's back up even a little further and go to the instance and if you look at approvals somewhere in here is going to say my approvals under self-service you could take the filter out and see all approvals the name of this table is sis approval underscore approver that is a crazy name because there's also very similar related fields in that and there's other tables that are related but if you look up here it's called i can get there also by typing up here sis approval underscore approver very handy to know some of the table names that you'll be visiting in servicenow that's a very common one and what i would like to do is let's take this list and build out that filter from the filter tool for example let's say i'm looking for all the change requests that are overdue or have been sitting around for more than a week i would say show me all of the where the state is requested because if it's if it's been approved or it's not yet requested or something like this no longer required we don't care about those don't don't remind somebody hey you're we need your approval if it's already been approved so first i like to go for the state it has been requested and any of the other states really don't matter to me and the let's check the created date because i really don't know if it's been modified or or what's been going created on at or before let's say last week and we want just the change request now here's where we get into a concept we call dot walking it's how we jump from one table to another using a reference field now because change is extended from task i know that this approval4 column is set to the task table otherwise we use the approving table which is a document id and dot walking becomes a little creepier okay down here on the bottom of this list i have show related fields this is what allows me to do that dot walking to drill into the fields of a related record so if you haven't done dot walking before this is very handy now notice when i have approval for i have this arrow that says approval for task fields when i click that i don't think approving allows me to dot walk no it's a document id field so when i do that it now says you are in the approval for task fields and here they are this is no longer a list of fields from sis approval underscore approver the approval table this is my task fields and i can go down here to the task type which is on all the task tables and say it's a change request and hit run easy to build filter i always advise you to build a filter in the filter tool first rather than try to write a glide record query or an encoded query build it here first understand what it is you're trying to build and can it be done quickly and easily from here because this is a very efficient way to do it kevin says no fast forward on the stream nope sorry live stream community live stream kevin oh john says it's also weird that since most other table names start with cis underscore yeah i wasn't around in the very early days when they were naming tables how about core underscore company or cmn underscore location must have been like don's data named tables versus fred's data name tables i don't know so here i have 309 records that match this query pretty cool right so i want to find all these things that are overdue and send them a reminder maybe once a day so when i think of something happening recurring on a calendar or a timed basis scheduled makes sense remember i've got different ways to trigger stuff in the system i can manually trigger it through what we call a ui action i can trigger it when a record is updated through a business rule or a flow don't forget flows flows are i am gravitating so fast to flows after the last few weeks of of writing them and saying why do i need business rules really anymore so my use of business rules has become less and less my use of scheduled jobs is almost non-existent at this point unless i want to do some sort of hybrid where i'm i'm not going to get into that but before we had flows we had scheduled jobs and it would look like this hey run periodically every hour i want to send out a check for any overdue reminders check for this or you could say run daily run once one weekly on demand whatever so a scheduled job is meant to run on a timed basis and you would write some lovely little javascript in here i've conduct condensed mine tremendously by putting a lot of the code that does the searching and sending and whatnot into script include library functions which i have over here for example this one that says get overdue requests creates an overdue list returns an array it looks like this go out to the request table do a query create an array bring it back to me and then based on what you find there it goes down to another function and calls it a little later send overdue reminder get the record from each request increment the count update the record so i can say hey i reminded this person 15 times i reminded the other one six i reminded the other one three and then i triggered this notification via an event so i could pass it a couple of parameters then the mail goes out okay kind of convoluted when you think of setting up the registry entry getting the notification to react to the registry boom boom boom boom okay so what i did before right before flow came out about a year maybe 18 months or so i had heard there were some rumblings about ways to do this but it wasn't coming for a while so i put out a scriptless scheduled job update set it's out there on share i don't recommend you install this anymore it's usefulness has really expired but some people have and god bless them if they do this gave us more of that scriptless business rule functionality where you had a when to run and what action to take it was it was good for its time it did it fit a purpose and it did things like this pretty easily you could write a query to say go to this table and look up these records and when you find these records do this action even trigger an event which was kind of nice but again it was using a scheduled job and it's not supported officially by servicenow in fact i'm sort of deprecating this too i haven't done any work on it when people ask questions i say go to flow designer so what is flow designer well i'm sure many of you have heard of this but if you haven't i am going to go to my developer instance and bring up flow designer it allows you to create a series of triggered actions that are triggered either on records being updated sounds like a business rule that's why my use case of business rules is becoming less could be scheduled which is why scheduled jobs are almost non-existent in my vocabulary now it could be on an email import it could be attached to a catalog entry there's a lot of things that can trigger these flows so i'm going to show you a simple one here that i used for an example i have used on previous videos for my projects and courses and tasks and videos and some of these related things and when it comes up wait for it wait for it course approval oh that's my reminder i'm sorry that was the wrong one i need the course approval where's the flow sometimes it does this kind of thing and it pauses and it feels like it paused a little too long so i have an approval reminder that says wait for this record to be updated when the state changes to approval i'm going to go out and use the ask approval these are so easy to build it it doesn't take much to build an approval workflow and flow designer is our next generation of workflow you're still using the legacy workflow this guy this question comes up a lot using the graphical workflow engine that we came out with in 2008 fine continue to maintain those flows but if it comes to building new logic new business rules new schedule jobs new workflows build them in flow designer easier to build we're adding functionality to it in every release in fact in a couple of weeks you'll find out what we're adding in paris flow designer and integration hub have been have been enhanced quite a bit again and they will continue to build it we're not in we're not adding any new functionality to workflow and its orchestration companion product so flow designer flow designer flow designer as i wanted to make a t-shirt a couple weeks ago go with the flow [Laughter] all right so my approval says i want to ask for an approval i'm going to approve or reject when anyone approves or rejects my anyone is me you could put in a group you could put in the data pill which is live interactive data and notice down here there's a due date field oh this wasn't available on approvals before this is part of flow designer i could automatically approve it when a date comes up and say automatically approve it 30 days from now or reject it or cancel it and say you know what when the relative date is 30 days from the creation of or the course start date or something you can have this done and you can add a day schedule in here using the scheduling option that we've got for a lot of the other records business days eight to five monday through friday excluding holidays whatever you want you can use a scheduled uh calendar that way not just raw days very handy but that's more of a termination okay you might want to look at doing this and say okay 30 days after this approval is created i'm going to cancel it very handy feature i'm really glad they put that in there so that's what an approval looks like and of course i go through some logic to say if it was approved do this if it's cancelled do that otherwise you know do something else so i've got my simple approval this takes maybe 10 minutes to build if you're slow now what i want is my approval reminder i'm going to do it on the same use case that i had before around the change requests is that something a lot of people commonly do so let's go and create a new flow new flow and where do i get one of those go with the flow shirts i'll see if i can make one for uh see if we get our marketing team to create one i think that'd be a lot of fun we have we'll give this flow a name i don't think my name works very well so let's do change approval reminder and we'll go with that for now i want to run this nightly so here's my trigger record created nope date daily looks good application i could do inbound we talked about that so let's do daily at eight am i'm going to run this flow easy trigger not a problem what do i want to do first thing i want to do is look up those records just like the ones that i found from the list so action and it's in here somewhere there's a lookup record there's a lookup records look i just typed look up here and look up records plural i'm not just getting one i'm getting zero to n it could be zero it could be a lot more select table approval is this one sis approval approver and all of these conditions must be met let's do it again state is requested and created or before this date picker is a little different than the one we saw on the standard ui so let's go weeks last week and we're going to drill in this time we've got a nice little arrow already on approval for i can say task type i love how the little search window helps it filter down oh not catalog task i want change request there's my filter all right maximum of thousand results that's fine if i have more than a thousand we'll get them tomorrow i guess or you can up that if you like going higher on this search means it could take longer to find these records so be aware of that when you're doing lookups just like anything else the more records the longer it's going to take to query there's my lookup when i have this it creates new data pills over here on the right just behind my head let me scoot down a little bit there you go i've got a list of approval records that i want to iterate through so i go to my flow logic for each drag this data pill over here optionally you could use this data pill picker here to say look up records approval records same thing it puts the data pill in here and says i'm going to use the approval records from action one you can see action one is right over here and that's it now i get this little branch that comes out and says for each record go in here and do this what do you want to do well you probably want to send an email my system is not set up for email right now but what i'll do as a substitute is create a log action if you want to send mail you send mail this way actions servicenow core send mail pretty easy and i'll give you one other hint i'm going to go through this but i won't save it the target record is going to be a data pill oh it actually doesn't make you force forcibly take the table record or the the two required fields are two and subject thing to note about two is it would be real easy to say go into my approval record in the oh and take the approver get that out from behind my head take the approver that doesn't work i've already tested this doesn't work it's not as smart as say the notification record the issue here is it recognizes this as a did you see it did you see it an approval record approver is a reference okay it contains a sys id you can't send an email to a sys id that's not going to work instead what you need to do if you want to send this is go for each approver and get the email from this record sad but true you have to put an email address into the to address ooh shocking i know okay that will get them the email and if they don't have an email address and it's disabled you're gonna have to debug it through standard normal ways to do that okay then of course you put in your subject you can put in data pills and whatnot for the body of the message blah blah blah okay that's my one tip about sending email in flow designer you got to put the email address in there okay once you say it it makes sense what do you put in an email address field an email address okay we've been cheating on the standard ui for years by putting reference fields in there because the backend engine goes oh this is a reference assist user therefore i'll check and see if they have an email address and use that instead handy but doesn't work here why does that not work couldn't tell you the flow engine code is different than the back end engine code for sending emails i guess and it knows different data types a little little more i guess if you were if you were talking about code this would be a little stronger type checked not strictly type checked i'm going to put in a log message just to watch it go through these records my message will contain the change request number so i'm going to go into the approval 4 and get the number and you know what that's enough for now i could put in the approver's name and all that stuff picking from data pills is a lot of fun let's save that you think we will get the option to loop back to the main flow in future release like roll back in workflow chad that is on the backlog i know that jake is aware of that and he's heard it a number of times uh i don't know where on the roadmap it is and if it was if i did i couldn't tell you right now anyway so honestly i really don't know i haven't seen the roadmap of what features are where for that let's go ahead and click test up here might be a really short episode you see this is way easier than trying to write some javascript i didn't write any code here it's it's easier to build it's easier to test it's easier to maintain here is my stuff because think about it in two years when somebody else steps up you know you go to a different organization you get a promotion into a different part of the organization whatever it is someone's going to have to come back and maintain what you've built so the less code you can do the better off you'll set up your organization for success it's not all about hey trust me i'm i'm a computer science guy my brain normally goes to scripting and coding first it's not always the best idea i have to constantly remind myself is there another way is there a better way to do this and challenge myself explore new things maybe maybe you got to write a custom action but custom actions have a little bit of script and it's very reusable when you put it in here okay enough about that you can see from this area on here get my bullseye on there that it has gone through and run this loop 309 times complete complete complete complete and if i open up this log statement look down here and i've got my right behind my head again you know what let's put my head away bye i've got my change request and if i click through these ago number one number two number three number four there's a lot of approvals on number 76 that's why it wasn't changing those approvals were all for the same record it probably asked for a group approval on that one number six 81 81 81 81 there's a whole bunch then it goes to 39 and if we look we probably have that multiple records for multi multiple approvals for multiple records 4004 has quite a few of them 96 has quite a few of them and if i do this group by approval for you will see come on [Music] pdi three five five five it's not uncommon to do a group approval rather than a singular approval and a lot of these do have probably the same group on here okay let's open up 69 we've got kristin bernard luke howard ron kristen bernard luke howard ron it's the same group we can pretty much infer that from the uh the output so inflow designer we know our flow is running we can send these nightly bash out a whole bunch of emails say your thing is overdue now where would i take this on the next step get back in here where would i take it on the next the next level would be to track those approvals and say how many times did i approve them when was the last time i approved so or reminded them excuse me how many times do i remind them and when is the last time i reminded them that's a pretty easy thing to do approvals are in the global scope so wait for that to redraw and i get the ability to configure the table now make yourself an update set save all this do what you want to capture this the proper way but the idea here is i would then go and say last reminder would be a date time field and number of reminders ah that gets into some interesting stuff anybody watched a video recently where i was putting those in you can do that it's uh i think i was talking about custom actions i'll have to find the video that i referenced but incrementing a field number is not something we provide as an action today setting the current date is not something we provide today but they are very small reusable components that you can build to keep track of that very easy oh it was when i was doing the loaner request the the app on the fourth look for the june 4th um i think it's topical deep dive and i built a couple of custom actions so do just that so june 4th community live stream let's even get a link into the show notes so that you can find that this will be an integer and now you could do some reporting who are the chief offenders who's been reminded more than five times do i need to start a different flow that reminds their manager a lot of different things you can tack onto this once you know this information very easy to do the approval table is not sacred you can modify just like an incident table just like anything else just keep in mind that these are going to be called you underscore last reminder you underscore number of reminders so on and so forth initialize this one to zero which would be helpful that way you can always take out your null data and add those fields generate the flow then when you send a reminder in your flow go back here unzoom that you can do an update record what do you update record well you update the approval record which is sitting right over here behind my head again on the data panel and say update this increment that field set the date for now and away we go pretty easy right you can do that uh jonah's question is a second jonas question is there a way to trigger the notification instead of managing a new template yes there is there is and you will it's uh you'll need to create a notification first so this is this is an interesting sidebar on notifications because i like to manage all of my notifications in one place under here in system what is it system notification notifications let's keep everything in one place not some in workflows and some inflows and some in notifications this is my central repository of notifications you can create a notification in here and i forget what release it was it was madrid or new york i'm pretty sure to say send when triggered took me a while to figure out what this triggered was that's triggered from a flow well to get there you need to create a new action so let's do that because there is a send mail step in there that says which notification do you want to send so send change reminder email i did that i will i will leave that as global why not because change is in global give it some inputs like who do you want to send it to etc etc i'm not going to go through the whole process of building a custom action here but in my custom actions i have send an email and one of the things no i'm sorry that might be the wrong one the that is the wrong one i always get that mixed up it's where is it did i miss it notification i got hung up on on the end of one of the videos not too long ago about this one trigger a notification not send email that'll do the same thing we were just doing out on the flow this is inside an action and the record will need to come from this but notice that i've got my notification list of notifications that can be triggered right now it is password reset and password required updating so yes i'm tying it to a specific notification and i'm making that action notification specific so this will be my action to trigger a change request notification if i had one there if i look and say what is this field send when triggered let's go back to notifications and i'll bet you that if i get the active ones oh i just duplicated the filter act if it was true active equals true it doesn't do you any good and send when is triggered i will come up with those two notifications oh i get a whole bunch of them neat password reset send verify code password reset there are seven of them why don't i see any of the other ones i don't know that's an intriguing question maybe don't know why don't i see seven in that list so makes me wonder i'll figure that out for you so that's the beginnings of creating actions i'm going to go in a little deeper dive about creating custom actions and even integrations at some point so stick with us on that that is all i've got for uh creating a an approval reminder use flow designer is your go-to i want you to as one of my colleagues said i want you to retrain your muscle memory i'm i'm doing it all the time from reaching for a script a scheduled job script in this case to reaching for flow when you've got to do something on a scheduled basis it's taking me a while again i've got close to 40 years of writing code so my brain wants to write code it's it's retraining that muscle memory to go can i do this in flow just asking that question same kind of question you see when you see hard-coded strings in your script should this be a property should this go insist ui message where can i abstract this so that it doesn't me later it doesn't cause technical debt speaking of technical debt if you haven't already seen or heard i will be doing a talk with david lu yes that david liu the one that's in the demo data one of the founding fathers of servicenow he runs a company called perspectium uh he's been doing that since i think 2012. i'll be talking to him on the 22nd so the day before paris comes out if you like send me a message or look for my linkedin messages or twitter messages you'll see there's a there's an announcement that we will be doing this 8 a.m pacific time we're going to be talking about technical and data debt so just a fireside chat kind of thing nothing no demos no rehearsals just him to me on a zoom talking away love talking to the guy extremely smart his phd in computer science i believe dr david lew if you didn't know that so a little more servicenow history trivia for you look forward to talking to him that is in less than a week wow 20 seconds really where did july go slow down time i got to catch up here so thank you very much for joining me today i look forward to speaking you on monday the 20th it's already the 20th oh this is the sad part about getting old monday the 20th when i'm going to address one of steve from sweden's questions on how to make your script includes and all of your server-side code just a little bit easier to maintain you've probably seen me do this trick before but this is going to be the definitive source of how to set up this central area of less changing less searching less just you you'll see join me 2 pm utc on monday the 20th for a special thing about script includes and server-side scripting so i will see you there until then i wish you all the best stay safe be kind wash your hands all that good stuff talk to you again real soon bye [Music] you
https://www.youtube.com/watch?v=J5mlDzfl-So