logo

NJP

Community Live Stream - API Adventures - gs.eventQueue

Import · Dec 10, 2020 · video

[Music] so [Music] [Music] do [Music] wow [Music] do [Music] so [Music] [Music] [Music] [Music] [Music] [Music] [Music] wow [Music] [Music] do [Music] [Music] [Music] [Music] [Music] [Music] do [Music] [Music] [Music] do [Music] [Music] [Music] good morning good afternoon good evening wherever you are and whenever you are welcome to the community live stream my name is chuck tomasi senior developer advocate at service now this is december 10 2020. 2020 is almost over hang tough with me people the end is in sight just a few more days our topic today is as you saw from the title screen gs.event queue what does that mean it means we're going to be exploring what the event queue can do how you can control it how you can put things into the queue what the different parameters are some of the flexibility that goes on there i will show you all of that good stuff on this episode of ap api adventures see we can get this out today as we go forth but first let's get through all of the intro stuff as quickly as possible good morning to everybody who's joining us live on the live stream on youtube on twitch thank you very much for joining in the chat i will be glancing at that from time to time to incorporate what you've seen what mistakes i've made that kind of thing in the meantime if you haven't done so already go and click subscribe click like you know what to do it's youtube my phone is around here somewhere so that i can show you when you do that you get the alerts on your mobile device like that says hey it's live go get it that's why i start streaming a little bit early so you get those notifications you can cue things up and get your desk in order the way that i get my desk in order as we're getting ready to also make sure that the streaming is working rather than when i say it's time to go live and it doesn't go live and you're sitting there waiting so now that we're all in our seats and smiling faces and ready to go and you've done everything with youtube and turned on notifications that kind of thing as well as twitch well maybe twitch is your backup plan and you have a backup to your backup because all good administrators all good developers have a backup plan right right we've all been there we've lost work we go oh i should really save more often or i should have a copy of this before i start making big changes okay i'm going down rabbit holes right and left today i don't even know what's going on let's continue on if you've got questions be on the gs.even q then please i invite you to go over to the community community.servicenow.com is where you can ask those questions please get involved with that and ask your questions there somebody sent me an email yesterday and i apologize i couldn't answer as quickly as possible that's not the best way to reach me that's not the best way to get your answers and as it turns out you got his answer from the community anyway so you're welcome to try you know there are the occasional persons who send things to me via linkedin but it might be a week before i respond to some of those messages so getting getting scripting support through linkedin or email to me is not the right idea go to the community it's a lot faster there's more brains than just one one that's trying to time slice between about 15 projects so please go there community.servicenow.com and ask those questions in the proper places of course if you've got questions about itom there's an itom section if you've got questions about reporting and performance analytics great that's a great place to go there are specialists in those areas that can answer those questions you know what to do typical community stuff communities have been around forever our developer site got a revamp earlier this year so i invite you to go check that out if you are new if you're just watching this video for the first time i know some of your old-timers are going come on chuck you say the same thing every time get to the good stuff get the good stuff well there are lots of people that are watching this video for the first time and i want to invite you to go to developer.servicenow.com there was somebody in a meetup on tuesday i believe it was there were three meetups on tuesday developer meetups that i'll get to in just a second that didn't know about this how can i get started i'm new to servicenow where can i go you can go to developer.servicenow get yourself a free personal developer instance this is a real instance of servicenow that has all of the goodies loaded so you can go exploring you can turn on things that are typically a pay for product you got to use your instance every few days otherwise it's going to go to sleep it's going to go away because we only have a finite number of instances out there because they are free we don't just say here have it have it and have it forever and use it whenever you like that would get a little expensive and we do need to control costs and be good stewards like every good corporation but aside from that free learning plans so you can start down a learning plan that will remember where you are by the way and you can continue learning and growing and evolving your uh career to get more knowledge get more pay get a pretty wife or husband or whatever you want to get all right i'm not going to promise you the world but i can promise you that developer.servicenow.com is a great place blog entries we're working on a plan for 2021 to bring more stuff into the developer law a developer not just the blog but the developer portal developer.servicenow.com to bring you make it more centralized make it your hub of developer information which it's already got a lot of stuff we're bringing you more next year one of those things is of course meetupsmeetup.com pro servicenow dev program that's what you see over here like i said there were a whole bunch of meetups i think there's a couple more today i am loving every minute of it getting to meet with people all over the world from top to bottom from left to right from north to south east to west there are a lot of people if you look down the list we've got a couple of them in india dc is today washington d.c um what'd they say mumbai stockholm is coming up on tuesday the 15th there's one in phoenix tonight so even if you're not in the time zone these are being held virtually you can ask dhruv in the chat right how many has he been to in the last month that are nowhere near his time zone okay he was in vancouver canada and he lives in india so you can if he can do this you can do this join like-minded people and talk about developer topics learn and grow and sometimes they're open discussions does anybody have any questions sometimes they're demonstration of what people have built we had one in um oh i forget charlotte north carolina on tuesday that was talking about hardware asset management i'm not normally a hardware asset management person i stick with my integrations and my custom applications and my scopes and my apis this was enlightening i wanted to learn i learned a little bit more i found out all kinds of information so it was a small group that's fine it might be three it might be 43. that's cool so it doesn't matter if you're interested let us know go to the meetups you do have to join each group if you want to get notifications about those groups there are a lot of them that are trying to get their meetups in before the end of the year and there are even some that are spilling over into january so lots and lots of great information at these meetups can't recommend them highly enough please go check them out if you are also another reminder about some good developer content uh we just released another episode of breakpoint the developer podcast that i host i consider myself more of a guest a facilitator of this conversation we talked to josh nerius former developer advocate now in charge of many things integration hub and credential related great conversation if you haven't listened to it go over to bitly slash sn-break dash point you can listen to it live right there you can subscribe to it get it delivered to you for free through amazon or google play or apple podcast wherever you find your podcast breakpoint should be there if it's not let me know i even added it to a couple of uh new podcast directories in india last month so we should have pretty good coverage if you're looking for podcasts that way take it with you listen to it on your bike ride or when you're out running or you're vacuuming the living room wherever this is audio only so again no power points no demos no update sets we're just going to have a conversation and we have a lot of great stuff lined up for breakpoint going well into july okay i i started sketching down ideas of what do we want to talk about because my backlog was a little light and we've of course we've got quebec stuff coming up in january february march we're going to be laying that all out it's every other wednesday so we delivered one on the 9th look for the next one on what would that be the 23rd i'm doing really terrible math right now so we'll go with that breakpoint is the developer podcast please go check it out i and thank you everybody who has i've read lots of great comments on linkedin and youtube and other places saying they're really enjoying it the conversations are getting better which kind of makes me wonder what happened to the first few okay less than a week to go to register for the next tech now tech now episode 82 is all about instance data replication we've talked about this in a couple of the recent developer meetups good conversations around that i think vancouver was one of those bitly slash tn 82 reg this is free okay you do have to sign up for this one uh you don't have to sign up for the community live stream so oh as soon as i get back to the camera i'll make another quick announcement don't let me forget don't let me forget there's some changes coming so go check it out tuesday 8 a.m pacific time and if you miss it i will have it online on youtube a few days later but you're going to have to wait because i got to do some post production to it we will be doing a little bit of javascript today so you can find our sample scripts that we write over at bitly sn-cls what's our next slide if you want to get more comfortable with javascript please go check out the video series again thank you to everybody who's giving me feedback on this a lot of great comments bitly slash sn-learn dash js takes you if it takes you from you know you've never written a line of code in your life to uh you're feeling comfortable with it you can recognize some of the things and be uh enough to be dangerous okay or go take the scripting course get ready for scripting and service now on now learning that kind of thing maybe you just need a refresher of from another language go hey i've done python for 20 years what's new also want to remind you that a new series is out launched december 1st 2020 called learn integrations on the now platform go over to bitly slash sn-learn integrations this is the first two chapters of what i presume is going to be about five chapters of content so we've got a lot of great start get that to you go check it out i know there's a lot of things to look at on here and all of these links are going to be in the notes i believe they are if you're watching this video most of them should be if they're not shame on me i'll get them in there okay let's get on with this quick reminder about the announcement that's coming up this series will be changing in in formatting schedule and some other things going into 2021 uh it will probably be closer to february before i get the legs under this thing because there's some physical and virtual changes that need to happen so i will still be bringing you this type of content but in a slightly different format so just want to let you know things are changing if we don't meet on mondays and thursdays at this particular time anymore well it was fun while it lasted but we will continue to meet and i will continue to bring you content there's just sort of more of a structure going on between the various productions that we're doing so we want to bring that together make it easier for you to consume easier to find that kind of thing so watch for changes in 2021 it wouldn't be a new year if we didn't have new ideas right that was kind of cheesy wasn't it [Laughter] let's get on with our topic oh it's a rare morning isn't it at least it is for me okay i am going to be talking about gs.event queue this is part of the glide system class of apis and if you look on let me get the right pointing device if you look on developer.servicenow.com or docs.servicenow.com for glide system you will find all kinds of stuff you can add it's it's got all kinds of things you can see down here on the right hand side left hand side excuse me get display column get message we've talked about get message for doing translations get property many of you are familiar with gs.get property next to glide record i think glide system or gs is probably one of the most popular apis we've got and there's one about events that i like talking about because this is the original way we used to trigger notifications before you said hey when a record is inserted or updated and the thing changes okay that's a great way to set up your conditions of when you want something to change but there may be other times where you're off in javascript land and you say i'd really like to trigger a notification here even though i'm not updating a record it's just time okay that is perfectly doable we can do that through the event queue by setting up a registered event i'll show you that with a new little trick i've got you can you can either trigger from existing um existing events there's all kinds of events that are happening in the system let me look at this if i go to the event log just type event log up here under system policy events event log right there easy enough it brings up the event log one of the most frequent ones is glide.heartbeat this is just something that's going on in the background saying hey this is still there is it still there is it still there i'm going to filter that out so we get a little more generic about this incident.inactivity there's an activity monitor that happens i think it's once a minute to go hey is there something out there i should know about and it triggers this event every minute now there's nothing happening based on this event but it's happening it goes here's an event here's an event here's an event and it's up to notifications or script actions to listen for that event and the event engine goes ah i'm going to run you i'm going to trigger you okay here's one called student count apparently i've got a script out there course change we've run these i need to look at why these are triggering because they shouldn't be right now oh it's scheduled okay we're going to do a little experimentation with this later so keep your eye on those these are from a scoped application you can see the scope name in front of there session established log in anytime somebody logs in you could run a script why not these are just events let me show you how this works i've got a sweet steve knows all about this i've got a new tool called a remarkable one of these e-ink tablets and i'm going to bring up one of my notes so we can do this about my glasses with the studio glasses on come on hit it of course now it's asleep i set it down and i went to sleep there we go and i'm going to do live share so we should see this on the screen in just a moment it takes a second for it to bring it up and i will this is kind of a whiteboard that i'm going to do for you i put a few blocks on here with powerpoint earlier exported to pdf and imported it right into the remarkable device and i'm waiting for it to say hey someone wants to do a live session let's try that again always interesting doing technical things like this for the first time tested it a couple of times before we uh did this and i may have to stop and restart the app wait for it okay in the meantime while it's coming up if you haven't seen it nice little thin tablet i could hold it up this way but it makes it really hard to draw there it is accept the connection and i have a live session live okay as i draw you can see that and i can erase kind of fun right works well for webinars this kind of thing hopefully that will erase in a second oh it's not erasing now we're uh stuck again if it's not erasing that makes me nervous okay so we've got our gs event queue script over here on the left the left of the screen this would go in any server side script to say it's time for me to cue a script that makes me nervous let me turn off the live view i'm going to restart this just because this does say beta on it it says to a live view beta remarkable close that let's go to you know what i also find annoying is this dialogue doesn't go away gotta write them about that open up the diagram again live beta wait for it to come up where's the rfc for 2021 [Laughter] okay there's my accept again and we've got an event processing engine we've got an event queue that would be the list that i just kind of showed you things go into the queue they get processed by the engine so this picks it up and then it gets turned into a notification or a script action and we need to have our event registered from the event registry before gs event queue can stick something in there okay that's all i wanted to do is draw some arrows okay the it's up to us to add additional entries in the event registry if we decide to create our own event we need to put it in there and also these i'm gonna sort of make that a dotted line that was uh you know what i think the erase kind of makes it go wonky no it just doesn't do erase very well okay good to know it does not i wonder if i can do it with the erase icon erase yes i'm fully aware of what erase does and eraser no it doesn't erase anything you put on here bug maybe that's why it says beta we just learned something so when you trigger a notification you can trigger it by event but you have to have the event in the registry first okay enough of the technical fun let's go see how this actually looks when you do it in an app or or something like that so um let's see here's here's what we're gonna do today we have a parent table and we have a child table let's go back to our favorite community live stream app that we like to pick on because you know i like to pick on something other than incident i've got programs those of you who've watched this series before no this table structure kind of we've got programs and under each program we have a number of courses if a course changes i want to notify the program owner that the course has been changed or added and i would like to include in an email all of the listed programs sound familiar when a request needs approving let's go get all of the details of each request item okay so we're going to do that but we're going to be doing it a little differently rather than in a mail script well we may use a mail script a little later but we're going to trigger notifications rather than say hey a notification was a record was updated okay so i could do it this way notifications system oh where are you system notification notifications and if you've done notifications you've gone through your basic sysadmin course you've done some development before this will look familiar you pick a table and you say course changed pick the program table and hmm but i want to know about the child record changing to notify the program manager that's interesting so maybe i better do the course table which is this one and say if there's an update i could also do event is fired that's what we're going to look at soon and something on there changes who will receive it what it will contain but i need to send it to the program manager so i could say use groups in fields so let's get the program owner and send it to them so i could not walk my way to this but i'm going to do it a little differently i'm going to do this from an event why because i may want this in a ui action that doesn't necessarily change the record it just says fire the event okay i don't necessarily want to do this from a record change although this one implies that i do if you look through some of the older business rules and script includes and whatnot you'll see gs event queue used in a lot of places to trigger these types of incident incident.events is a uh a business rule that checks for a lot of that stuff and triggers events at least it used to i looked lately where was i going i was going to show you a basic example of what gs event queue can do so first let's go and try running one from scripts background system scripts background paste and i am going to call x under da da da da course change first thing i need to note do i have this in the registry registry this is a really really easy table to do that's performance analytics system policy events registry down here on the bottom and i do how did it get there well i created it by saying new record it says this is in the cls app so let's get to the cls app and you really just give it a name okay if it's a scoped app it's going to have the scope as a prefix if it's a global app it's not okay you want to typically events in global scope we'll start with the table incident.updated is a good example incident.assign to use descriptive names but make them easy don't just call it assignment change that would be bad we often use a an underscore notation or a dot notation to separate these much like system properties are if you're familiar with that and i tell it what table this event is going to react to so there's a tie in here the fired by and description fields are really for your own personal documentation fired by nothing this is a test okay that would be very bad for you to look at later description uh but up here you would possibly say fired by business rule uh course change description trigger the notification blah blah blah blah blah also down here something that was added a few years ago that wasn't originally in the implementation that i started with is show me the business rules that are related to this show me the notifications that are related to this and it will say well i'm going to look at the business rules that are on this table i'm going to look at the notifications that are triggered by that event or excuse me on that table also so you see from the breadcrumb it just did a nice little filter for you on that table good start gets you in the right direction i do have a notification but as we saw a minute ago i created it in global which was not what i wanted to do let's delete that excuse me must be time for a drink of tea create your files in the right scope ladies and gentlemen so i have the registry with this that's kind of where i was going course change not too hard to enter it's just a simple stupid straight up record in and of itself it doesn't do anything except say i'm here okay it appears in let's go back to notification if you don't register it you can't use it because if you go to let's see we can spell today system notification notifications if i were to try and when to send and say event fired it tells me all of the entries in the registry table okay and you look closely down here x underscore this is why that's why i wish this was a reference list instead but x underscore 66238 course changes there if i didn't register it it wouldn't be there i couldn't trigger the notification sounds simple when you say it that way of course it is so let's go back to my sample script and go to scripts background i am going to trigger gs event queue now according to the documents it's got five possible parameters there's a four parameter version and there's a five parameter version i don't think that one's up there first thing is the string name that is the name of the event being fired you pass it x underscore 66238 underscore cls 323.course under exchange okay that's the name of the event the second is a glide record doesn't have to be current current is available in a lot of places but when it's not available you have to go look up your glide record so you need to pass it some kind of glide record or as you'll see that me do you could pass it a null you know i don't really need a glide record for what i'm going to ask you to do just do it then there are a couple of string parameters that you can pass hello world who's the user id that triggered this what time it was fired all kinds of useful information that you could put that will end up in the event log but it's also consumable by the notification and consumable by where is it still up there by the notification or the script action either of those can get at those parameters so when you pass it with gs event queue it goes into the event queue the event queue gets picked up by the processing engine and your script actually it's like hey i got these extra parameters that i can latch on to maybe you want to pass it a list of email addresses that were not accessible through current they may have to be looked up they may have to be somebody else looked them up passed them in through the parameter go hey i got my notification i got i know who to send it to it's a wonderful thing second parameter same thing just for fun you've got two and then q is the name of the event queue that you're going to put it into if you look at the event log see if i can find this faster this way maybe event registry event programs events created on today not equal to heartbeat there is a q column over here text index is one of the most common you'll see i have yet to find out how to use this it's not documented anywhere as far as i can tell this is not meant to be used by mere mortals it is something that the platform people doing their java stuff in the background use so most of the time we ignore it we don't even put on that last argument it's the four that are event name glide record parm one part two done i don't know if there's any advantage to say hey go stick this in the text in the esq or what happens you can't just make up cue names i tried believe me i called it chuck and it just sat there unprocessed forever so don't do that you don't want events that go into the event queue and don't get picked up so generally we leave that one off you may see it hallelujah if you figure out how to use it let me know because right now i got nothing meanwhile back on our example i am just going to trigger this event not give it a glide record and not give it any string parameters and i'm going to run it in my scope run and it looks like nothing happened but of course if we go back to the event queue and refresh it's sitting there it's not processed it's not processed it's not processed takes a couple of seconds okay the event engine may be backed up the event queue may have thousands of these things think about when you import cis every time you import cis it's triggering an event called ci dot updated or is it updated.ci can't remember but it's a busy one because you forgot to uncheck run business rules and now there's 15 000 events in there that the event engine needs to catch up and go do i need to do anything no do i need to do anything no do i need to do it you get the idea at this point it has been processed so it was entered at 729.53 you can see if we scroll over to 29.53 took about 15 seconds to run and process things don't happen immediately when you throw them over to the event engine they do happen but they don't happen immediately so if you're expecting exact on the second real time updates events are not for you meanwhile let's make it do something a little more useful i don't even tell you how long it took to process processing duration one one whole millisecond [Laughter] well that means it really didn't do anything let's get our next example out of the library we are going to just pass a couple of parameters in hello and world okay you'd see same event no glide record i pass it a hello and a world why would you want to do this again well it could be for diagnostic purposes i may be debugging something you just go this is a test this is a test i'm just testing the event to make sure it fires and whatever it fires runs the script or triggers the notification you can do that i do that a lot i use parm1 and parm2 for debugging purposes and then when it's in production it does something a little more useful the other cool thing that i found is well let's let's get a little more savvy we're going to pass it a glide record but remember in scripps background i don't have a glide record i can just pull out of the ether like current or previous or yeah no it's not there so i'm going to do a lookup on one of my programs this is constants.program table if you are aware that's just a script include that defines what is the physical name of my program table so that i don't have to remember x underscore 66238 underscore cls 323 underscore program that's not any fun to write this is a little more human readable and if i want to change the name of the table at some later point i can do it in one place and all the scripts that use constants do that okay quick background reference get the record by cis id and then pass it here why do i care because i may have a notification i may have a script action that is expecting that and can use that and if i see this in here it is now hello world the table has now been set it pulled that out of that glide record parameter so that it can trigger the right event on the right table remember when we put in the registry excuse me let's see if it is actually processed there it's now processed that one took a little more from 3252 to 3310 and took five seconds that implies it might have done something i don't remember if i have a script action that responds to that event nope i will call it student count but i do not have one that has anything else do i have a notification system notifications notifications down here um let's look for and when is event is fired and scope nope sorry application is cls do i have anything i don't have any notifications what it spent five milliseconds doing i don't know but we could make it do something for us okay next example i'm just firing these events and letting the advantage and pull them up let's do something a little different there is a similar api to gl gs.event queue if you scroll down here there is event queue scheduled okay does what it sounds like it puts it in the event queue but it doesn't get picked up until the time you specify in this last argument so it swaps out the queue for the uh the expiration date is what they call it now it says it's an object and the example code example shows a glide date time object so let's go give that a try because there's something i discovered that maybe somebody else noticed same beginning i'm going to get a glide record i'm going to instantiate a new glide date time called gdt i'm going to borrow that and say this is now so that i can put it as one of my parameters and go here's when it was fired obviously i could get that off the creation date time of the event as well i'm putting scheduled in as my second parameter nice for debugging and then passing gdt but i'm adding 15 seconds i say i want this to fire in 15 seconds from now so let's go back and look at that test it out okay gdt is going to be now i add 15 seconds to it and pass that as my final argument watch closely and observe let's go back to our event log because by the time i get there 15 seconds will have passed we're going to do a show matching on this just keep an eye on it there's my scheduled it went into the event queue parm 1 says it's currently 7 35 58 which corresponds to this up here right created 7 35 58 oops i drilled in apologies 7 35 58 this is my scheduled event it says processed empty processing duration hasn't run yet hasn't run yet i've been talking for at least 15 seconds and it's processed okay the surprise i had before was i thought it was time zone savvy but it is processed so i can say process this in the future it was then processed at 3628 which means it was about 30 seconds 32 seconds from the time it was fired so 58 to 28 30 seconds exactly so it took 15 seconds obviously i wouldn't do this on a 15 second there's no point in delaying it because you're going to get that delay anyway but if you wanted to delay seven days or 24 hours or say hey go and do this thing a week in the future you can do that so gs event queue scheduled does the same thing but it puts it in there and says you know i'm going to forget about this why don't you just go do that you don't have to have the scheduled job come up every time you go is it time to run is it time to run is it time to run just fire it forget it put it into a glide date time argument and say this is when i want my event to happen run the script or trigger a notification at that time next let's do a next because there's always another one um where was i going that was another one that did the same thing okay the one that i wanted to show you something that was interesting i am going to show you behind the curtains of our tech now series i have an instance and an application that helps me manage that people say how do you get everything done well my kids are grown i have a wonderful wife that takes care of time for me and i use servicenow to manage a lot of my uh processes so that's how i stay efficient and behind the scenes of tech now i probably should have gone to dev let's try that again techno div there we are so i can show you these scripts when we have a webinar it's done live people ask q a live after the webinar we get a spreadsheet from this third party service that we bring into servicenow has the survey responses it has the attendees it has what questions they ask there's a number of things in here that i use for statistical and reporting information the questions they ask are imported and we finish answering them and where they end up you guessed it on the community in italy slash servicenow tech now the final result of all of this looks like this if you don't if we don't answer a question live on the air we go answer it in the back end and then format the html and spit it out and it comes out something like this but this is all generated from that app the embed code for the video i've got a link to youtube i know where that goes the profiles for the guests and hosts that's all in the system as well the pictures they're referenced from the community but down here you see the questions and answers and i can tell who asked it who answered it i can send you an email to that link well if derek here asked multiple questions i don't want to send him seven emails i want one event to contain all of the information that derek had so what i do is get back here go to studio there is a ui action on the app go to tech now and when i'm done with all the processing and everything is in post-production go to episodes all i think i've got one in here this data is getting a little stale now don't think 81 is ready to trigger but there's a checkbox that says did i send the email if not there may be trigger q a notifications okay this ui action just triggers an event goes hey start the engine release the hounds do what you want calls question you tell send question emails let's go look at that so why i'm in jeopardy i don't know oh somebody asked me to make a change file switch tech now this is what it looks like a little more complex example than what i was showing you before i was just firing events how those events get fired let's go to server development ui actions generate there is a trigger q and a notifications is that link that i have at a certain point in the process we're done answering all the questions let's send the emails because they're out on the community and as we saw here it triggers question util send these things this is a script include the script include contains open that up a little bit more so we can see it i think i have this in sort of a reverse email html send question emails it says give me the episode and i'll take care of the rest good i like simple script include calls goes and says how many people did you get and down here you could see i'm generating an event queue what is in the event queue well check out this payload variable that's right behind my head that's not good check out that payload variable there it's generated from this i stringify an object what's the object the object is the html that i'm going to put in there what is the html that i'm going to put in there it's generate email html based on list list comes from the questions by attendee episode so let's see say derek asked five questions they are in a related list at the bottom get back to our record they are going to be found in the q a related list and it's going to say you know derek and mark and sally and priyanka whoever asked these questions then derek will come up again i want both those records not to generate two email but to generate one email so i go and look them up and i say what was the question what was the answer let's turn it into a little pretty html just with some tags then i can put that into a community post when i generate the email it will have the link directly to that community link in there so i know the cis id excuse me didn't really show that behind the scenes but if we look at oh i hope it's in here view page source and we look for derek nash that was blown up derek i spell it right no it might be frame source view oh i'm really bummed i can't find this it might be because it's a service portal thing but there is an html link in here that says it's on a div tag that has an anchor on it says if you want to link to this place this is what you need and then you can do that old hashtag trick on html i'm not going to teach you html right now but the idea is i send one email with one or more links because i'm using parm2 i'm using parm1 as who to send it to so this is going to trigger a notification called question posted let's go take a look at that notification it's all right here notification question posted should look like a notification that you've seen before but all i'm doing is really loading up those string parameters with an object and that object gets parsed by a male script so when event is fired on question posted i am going to contain this information notice also who will receive event parm1 contains the recipient to see that you need to go to advanced view if you don't see it you're on default view turn on advanced view and now because i don't know who that person is directly i've already assembled all this information from another source the q a table i'm pulling it together it's not in current because current or episode gr is where this thing is getting triggered look this is being triggered from where'd it go episode table the episode doesn't know who the email address is you can't dot walk to a related list of stuff you cannot walk from a related record to the parent record but not the other way around so i collect all this stuff and i say parm1 has your recipient parm2 has this list of stuff in the object so in what it will contain you should see a mail script hello name from payload payload is a complex object and then question list there's a mail script out there that processes the question list very cool let's go take a look at that under notification email scripts name is question list thing look in there and all it does look how tiny this is it parses out whatever's in parm2 and prints the html section of that object the work has already been done by the script include probably not best practice to do your html in a script include but i would like to make that more of a template so that i could change it and say i didn't want a dotted list i wanted a numbered list i could change it from a ul to an ol without having to go modify code but i'm not there yet you might want to think about that data driven stuff i hope that made sense how gs event queue is used to trigger notification that has some pretty complex data in there and how flexible that is because i just go okay here's derek's email on to the next one here's jason's email onto the next one here's preetha's email on the next one and we go on and on and on and on so very flexible stuff trigger an email you could as i mentioned you can also run a script action that's just a script that runs in the background and it uses current as that glide record parameter that you pass in so if i'm sending it one of my program records the script action has access to that very powerful stuff i think i covered script actions in an earlier episode yes i did because i linked to it in the description you can find that there gs event q and gs event q scheduled very powerful stuff that is all i've got i will see you next monday on december 14th to talk about how to relate to sort of related tables this is something that one of my colleagues came up with she had two tables they had two fields named the same thing with two values named the same thing but you can't not walk you can't do that so i'll show you how to hook those up as they're being imported watch for that on monday the 14th i will see you back here until then everybody invite you to join the developer portal the developer program sign up get your free personal developer instance go over to the community participate in that stay safe stay happy learn share help and i'll see you again real soon take care [Music] bye [Music] you

View original source

https://www.youtube.com/watch?v=jXkGt4iJsnY