Community Live Stream - API Adventures - GlideSession

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[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 and i am here on september 3rd 2020 to talk to you today about glide session this is one of those apis that personally i don't use all that often but there is some really good stuff in here that i want to share with you before we get that started just want to remind you that we do this on youtube mondays and thursdays at 2 p.m utc so you can do the math that would be 7 a.m pacific 10 a.m us eastern 3 p.m in london 4 p.m in berlin you get the idea 7 30 p.m in india until you all change your clocks again and then you get to adjust and i don't have to it's still always going to be 2 pm utc up utc doesn't change your clocks and if you're up really late like around midnight on sydney you can still catch this otherwise you get it on youtube you find it on the community you do the subscribe thing you do the like thing you click the notifications and with any luck the technology gods come through and show you a message like that it's streaming on twitch and it's going on youtube and everybody's happy awesome 10 pm malaysia time i think that is about the same time in singapore yes malaysia and singapore on same time last time i was in malaysia which was a long time ago about 14 15 years ago i'd love to get back there i was in singapore 2013 so it is pretty late and i appreciate everybody if i if i do this at the right time i can get the most most reach around the world and just a few people in hawaii that are still sleeping and maybe fiji we'll move on with that anyway we also do this on twitch as i always mention twitch.tv slash now community those videos are around for a couple of weeks if for whatever reason youtube isn't working for you or for me we can always fall back to that and if both of them fail i've got an mp4 that i'm going to upload as soon as possible so that doesn't happen that often but i do like to have backup plans as a wise man once said early in my it career there are two types of people in this world those that have lost data and those who will all right those are lost data start thinking about backup plans and backups to their backups so get in that mood good morning to everybody who's joining on the live stream thank you for joining me wow lots of great familiar names checking in people firing out the good mornings it's great to be here this is what gets me up in the morning just sharing knowledge and ideas and all this good stuff with friends thank you for joining hope everybody is doing well you are safe you are healthy your families are good everybody's taking care of themselves don't do anything foolish we will get through whatever we're going through right now so if you've got questions that go beyond the glide session material today please go over to community.servicenow.com that's what you see right behind me that is where tens of thousands hundreds of thousands of people are eagerly waiting to answer your questions and sharing that information because if you ask in the chat it's not very searchable if you ask on linkedin it's not very scalable if you ask me an email i might not even see it okay i do try to keep up on my email but it seems like lately my personal email is getting crazier than my work email so please the community is the place where you want to go because i'm actually as as these videos ramp up i'm spending less and less time going through and answering questions sadly i do go and get inspired by ideas for you for this content and then i can bring it to hundreds and thousands of people and we all get to see the code examples and sharing those snippets which i'll get to in just a moment if you want to and you haven't done so already highly recommend you go over to developer.servicenow.com where you can get free personal developer instance we are very close to launching paris for general availability but those of you who have been on developer.servicenow.com know that your personal developer instance had availability to the paris release since late july it's been over a month are you not looking at paris are you let's let's go people get on that and free learning plans and apis all that good stuff that you can find over there at developer.servicenow.com blogs we are increasing the um the the content in the blog to include things like podcasts the live coding happy hour we're architecting the back end management system andrew and brad and i are working on what we call artifact manager you may have seen us working on that we did a little bit of that we did a lot of bit of that on live coding happy hour yesterday special edition because tomorrow friday is a holiday for us as is monday for many people in the u.s so quick note there won't be a uh i know i normally do this on mondays and thursdays at 2 pm utc there will not be a community live stream on monday the 7th because that is a holiday i'm going to spend it with family enjoy your day off catch up on old videos see what we've missed or go and watch that four hour marathon we call live coding happy hour so all that will be over at the developer portal so much great stuff you don't want to miss it also encourage you to go to meetup.com where we have thousands of tens of thousands of people signed up for these developer meetups had a great one in matt madison earlier this week today's topic is actually inspired by the madison meetup uh it was late july or early august i forget the exact date but i saw this and went i have definitely got to share that so you get lots of great information i believe minneapolis had a recent talk about uh no i'm sorry it was min it was it was madison wisconsin had a great talk about some of the best practices and standards and and our organizers shared a standards documentation around scoped apps because they've got a lot more people building apps and they want to make sure that everything is standardized great discussions between developers it was it was so multi-directional ideas coming from other places and here's what we did and that's what they did and here's how i would approach the problem love these discussions that go on in the developer meetups and i'm trying to make as many of them as possible because they are virtual it's easier than hopping over to singapore and then back to london and you just jump on a zoom call now so enjoy them while they are virtual it is to everyone's advantage at this point let me make sure i didn't miss anything we got the meetups uh quick plug once again for the breakpoint podcast if you're not already subscribed go over to bitly slash sn break dash point is where you can find all the links to your favorite podcast directories or just use the rss feed directly or listen right there on the site there's also a page on the community with a player with all of them bookmark whatever you like but i encourage you to listen our latest episode came out yesterday i'm trying to remember what day it is it's the third yesterday was the release of our discussion with wolf wedimeier about now experience components again this is audio only so there's no demos no power points no update sets i like to say and uh go go give that a listen i've got another one coming out in a couple of weeks around upgrades we're going to be recording that later today so it takes me a little while to edit these and polish them and post them and get everything all squared away but it is a lot of fun we've also got another one special episode lined up for the later in september so i think i've got three episodes coming out four if you count yesterday's wow four episodes coming out it's supposed to be every other wednesday i'm getting ahead of myself but there's so much good material that i really want to share and cranking out an audio podcast is uh practically second nature at this point so go over i invite you to subscribe so you get it automatically delivered to you find it on all your favorite podcast directories etc etc the next tech now is coming up on the 15th of september just want to remind you this is our special session with product manager jivin john cower he will be talking to us about upgrades in paris how to simplify your next upgrade go to the bitly link you see there tn79 reg and get registered for that you'll get a calendar reminder 15th 8 a.m pacific that means it would be 8 30 p.m ist just trying to help you out again with the time zone thing i know you guys probably have this figured out if way before i do and we will be doing a little bit of script today so if you're not comfortable with javascript hey go check out this page bitly slash sn-learn js you can learn a whole bunch it's been very popular thank you very much to everybody who's been watching and commenting still getting comments on practically a daily basis about the answer to this lab exercise or comments on that really looking forward to our next video series coming up but if you want to look at the code examples that i'll be showing today they will be available at the bitly link you see there which takes you to a github repository just drill into the folder with today's date 2020-09-03 it will be posted immediately following this broadcast and you can find those scripts and we're going to do a script action and a script include an acl script and this is fun stuff so a lot of good things coming at you right now let's start with my personal developer instance of course i got that from developer.servicenow.com always looking for an opportunity to ring the bell alright and i'm going to start out and as i mentioned this is inspired by uh something i saw dan sinet from servicenow due at our madison developer meetup a few weeks ago and i don't use glide session as much as i don't often look for that opportunity to use that so real quickly i'm going to be going over a couple of specific methods i've got the docs page here for glide session scope there's a glide session global as you might have expected very very similar in fact i don't think there are any differences that i've seen and the interesting thing is there are no constructors so you don't say new glide session it's part of the glide system api so everything is gs.getsession.something else and we'll be looking at that dot something else in a little bit like get client data i've seen this in scripts and i didn't quite understand what it was until dan showed me this example and went wow that's an eye opener so to give you a little bit of layered technology a little bit of hierarchy api model if you will we've got things like system properties system properties can be used out of the box there's one called instance name there's one called glide.ui.sessionunderscoretimeout there's lots of system properties that we provide to guide the behavior of how the system or application should behave okay they're usually pretty static you don't change them every day you don't change them very often i would recommend if you're probably changing them more than once a month you're probably changing them too often and we should look at another mechanism they are cached so they're very fast to access but they're very fairly static and but they're very useful if you find yourself putting in magic numbers or strings or some sort of value in your application think about using a property i was looking at somebody's code earlier this week and it had you know this id and that's this id and that's this id in the script i went oh ow my head just hurts when i see that okay if you're putting societies into scripts you're doing it wrong if if if i were fred lady fred lenny i'd say i'd fire you but i'm not and i can't so think about that for a statement put that on the shirt if you i always want more t-shirts for some reason you ever noticed that okay so we've got system properties we've also got uh user preferences in the user preference table sysunder user under preference is the table and that holds things that are specific to you and me how do you like your incident list sorted on what field those are two different system properties to tell you the order and the field and the direction and uh you know do you want home pages or dashboards what was the last related list you were looking at on the change request form okay those are all user preferences because when you come back to a form or you come back to a list or you come back to an application you want to know what those are and we'll get into those we'll get into user preferences in a little bit there's also dictionary attributes which can set the behavior of a field or table behavior as well we'll talk about that i've got an upcoming episode in fact i think that's the next one i've got to look at my notes i'll i'll get to it at the end of the session i'll tell you what's coming up in the next couple of episodes so system properties user preferences dictionary attributes now we've got one called session variables these are exactly what they sound like they're alive as long as your session is alive as long as you are logged into the instance and doing something your browser is up you've got an active session and we can set these session variables anywhere we like it's almost like setting yourself a global variable for your session and say this user is a vip or right now the the value of x is 100 and you can interrogate that and use that with these session variables i don't know that i'd use them quite that openly but i'll give you a use case example where that might be helpful let's say you you want to best practice is to avoid doing glide record queries in an acl but you need to look at the user's record to find out if they're a vip or if they've got the role program manager or whatever it is normally you would do a glide record lookup but every time you display a form or a list oh man think about a list of 20 records and you're going through and hitting that glide record query 20 times just to display that list and it's always going to be the same value not a good idea how can we get around that we could set up a session variable ah this is like holding something in memory remember when i looked that up once let's hang on to that and make use of it so let's start with a couple of pieces so that's our objective we want to reduce glide record queries on an acl you may find other use cases for session variables we're going to make use of the glide session api to do that i need some t before i get this one started refreshing so i will start by creating something we just did in the last episode which is why it was before this episode there is a little planning that goes on here so we talked about script actions if you don't know about script actions there's a link in the description on the youtube video there's a link in the community post to the previous video so go watch those very helpful they're triggered by events and one of the events we want to take advantage of is simply called login if i look at the event log event log up here and just filter out glide heartbeat for a second see what we've got i have several of them in fact i'm going to filter out text index and user view is very common somewhere in here you know i don't think i even logged in yet i think it was still timed in so let's log out and log in and go back to the event log thanks chrome which is really recent events created today there is my login and logout events those were fired it says hey anything you want to do here is great with me so let's go and create a script action that does the glide record query once at login i'm going to go to my cls app and script actions are going to be under system ui policy or we could go through studio and do that script actions there they are system policy again i'm going to go through this fairly quickly because we just did an entire episode on this important thing to remember first thing and foremost is check that active field for whatever reason it is set to active false by default name is going to be set login cls params i don't have a good name for it today and my event oh i've got two events log in and log in i believe it's just by name so shouldn't matter i don't know if that's just something crazy about my instance go and check yours make sure you have one there's one way to find that out for sure let's save that and go to the event registry event registry is also all over the place i'm gonna just type registry and event name equals login we do have two one on sysuser okay and one on this event that's fascinating one is very old and one has been updated recently only you can't tell in that drop down list which is which so we're going to roll the dice yes i have my d20s right here [Laughter] let's see which one we get and we'll make it very easy so let's go back to our script action that we were working on we don't need a conditional but i'm going to [Music] save you the pain and suffering of watching me type a script i have a script action that does a simple glide record query let's walk through this together this should work let's put the this is easier to see here okay i'm going to go to the sys user table and use event.parm1 from the login now what was login um i look at the event registry again login let's go to the event log sorry a little too much back and forth here login has eventparm1 and an ip address interesting so i've got chuck.tamasi but that doesn't tell me about my account what i want is use that as a login to get the cis user record so i'm going to get the css user record based on event parm1 i'm guaranteed this is going to work i don't even need an if statement because i successfully logged in i get the record and then i call a script include now my script include is going to determine can chuck read this acl okay is chuck allowed to read this certain field there is a code field on my program table program it's some super secret code about the program there it is and i only want people with a role to be able to read that now normally you would put this in an acl i realize this is already existing acl feature and i could just put that it'd be nice and fast because the roles are cached and blah blah blah you think of another use case maybe it's chuck is it has a vip checked on his profile okay i'm just setting up some logic that's done once at login so that i don't have to do it repeatedly in the acl so let's there's my target i want to protect that i also need that script include created so let's go do that real fast system definition scripts and script and building things up normally i would start the script include layer let's call this program cls app and again to avoid boring watching chuck type error messages here's my script include it has one entire function called can read code and it says go out to the sys user has role table find chuck's society see if he has the role name program manager and if so your answer is true boolean otherwise you return false which was the default very simple to do nothing real terrifically complex but i'm not doing this in the acl every time i'm just doing it once at login and i'm going to store that answer so the acl can look at it later and it doesn't have to do a glide record query again avoid glide record queries in your acls because odds are the values aren't going to change whether i have this role or not until i log out and log in anyway it's not going to affect much so i've got my event i've got my logic that i want to run i've got my script action pretty much ready to go it says go take chuck tomasi get that send the sis id that's what get unique value is for instead of saying u.s id dot or plus space space just use get unique value it's a lot cleaner guaranteed to get the ssid in a string format you could also use get value assist id but i like this one it's it's there it's meant for us let's use it i put out a gs info statement and log just to say what i got in should be chucked out tomasi here is chuck's sis id and whether or not he has that role now i didn't check prior to this it's been a couple weeks since i wrote this let's go back to come on i want to unzoom this thing but it just keeps zooming around a different place there fun fun let's make sure can i update that i updated that okay i could also put a condition on there to say hey if this value is already set then don't bother but i'm not going to do that yet the other part is user administration there's me do i have this role it needs to be explicit inherited i don't believe works because i'm interrogating the table itself now i don't have the cls admin or the c the program manager role on here if i look and say role contains program nope i don't have that so theoretically i should get a big zero on this let's test the script include first like to test these things in the layers up i'm not just going to jump right into the action i've got my script include there's my program script include it expects a sys id and i'm going to call can read code so program can read code mysis id fastest way to get my socied in a script background is let's do var answer equals new program make that a little bigger for you so you can see it bigger nope can read code is that what it was i always forget and read code and gs dot get user id returns my sys id now let's do a gs.info answer run it says false chuck does not have this role very good that's what i expected going back to my user profile and granting that i could see edit under something something something program manager apply this role run the script again and now it says true rip include is working that's the important part it's returning me a boolean whether or not i have that role again there's already logic in acls to determine whether you have rules or not second thing i want to point out on the script action this was not something i knew about until dan showed me the the script actions run asynchronously they run in the background and when you run something in the background whether it's an async business rule a rest api it has a copy of the context you're running in what does that mean it means all the session variables all the other is copied it's run in that other session so that your foreground can continue on going doing what it's doing it's a very old and very common practice for doing asynchronous processing or forking a process the problem with that is if i fork if i create a copy of the current session and set a variable in the background when it terminates when the script action is done the foreground doesn't know i said anything so the real secret sauce to making all this work is right here gs.getsession.put client data and what i'm doing is creating a variable in memory in the in the session settings that the system can then go look for later the value i'm going to do is my cr can read value that i got out of that little script that i just tested this i made up it's a string it's an open string you can use what you want if you're going to start using variables heavily have some naming standards if you want to put a scope in front of it maybe you want to put your initials maybe something that that makes sure that they don't conflict you're going to need a naming standard just like how you name your script includes how you name your business rules how you name your ui actions all that other stuff you should have some standards around that so this is just like any other programming practice if two people call their variable program under manager you could have some issues so this is one of the methods of glide session again it's invoked through gs.get session it's called put client data i'm going to put it it sounds funny because it says client data but it has nothing to do with client scripts unless there's a client version of this that i haven't discovered yet maybe somebody could tell me that who's already used this this is kind of cool it's like a temporary property that i can pull back but as i mentioned script actions run in the background this is where it got a little and i'm putting a huge caveat on this there is a show xml there is a field on here old synchronous huh and this one is currently set synchronous false it will run in the background and i will lose that value watch you want to see a quick test if i do this and say let's log out and log back in now that i have that roll i should see a true value so this is the exciting part people where you watch your truck log out and log in someone's got to do it that away go to scripps background again and you didn't already guess the opposing script to put excuse me the opposing method to put client data is get client data and all i do is pass it the string and it will pass me back the value in its correct data type so if i saved a boolean i get a boolean if i saved a string i get a string let's do var cr equals gs.get session a little bit bigger for you please session right get client data program manager and gs.info cr not cd cr run that and i get a null because it ran in the background it goes hey you said it over there in that other context i don't know about this this is one extremely rare exception in fact this is the only time i have ever done this is when i'm running a script action and i want to save a client data variable do not make this a standard practice for your script actions it will defeat the purpose of having a script action you want your events to be processed in the background because remember those events may not be processed for a few seconds it could hold up people so i went to script actions if you must do this do so with extreme caution i'm going to elevate my roles to include security admin and here are my script actions if i go to configure security rules you will see the there's this metadata ripped action synchronous sys event script action dot synchronous there's a read read role and a write rule on this field and by default it is only available for maint that means servicenow people are the only ones i physically changed this i took out mate and i put in admin so that i had access again huge extreme caution on this you don't want a whole bunch of people saying i want my script action synchronous as well a very rare exception to this but you have to change that acl to be able to get edit access to the script action field here so here's my set cls params i modified my list personalization to put synchronous on the list and i say this should now be true and now when i log out that's the only reason i did it is so that it doesn't lose that value in the background one two three six log in run this again and i get a true it ran in the foreground set a session variable for me again you can run gs.getsession client variable in business rules ui actions script includes scripted rest ap anywhere you have server side script you could be running a put client data and a get client data to be using these variables as you see fit throughout your process very very useful i just needed this special instance on a script action to run in the foreground so that i wouldn't lose that value now that i have that value stored by the script action we can make use of it in acl so let's go back to our original property our original problem where we had the program iff table and there is my code out in the open for all to see and i need to create a couple of acls so let's go to configure oh i need to elevate again otherwise i don't get the magic menu option configure security rules and if i look i've got all my high level defaults up here then it starts to get into the exact table i've got my four i did not mean to drill into that four basic table rules for create delete read write make a new one that overrides those so i will create a read role on program program code and normally if i were doing this to just just check a role i would put it in there of course your basic sysadmin stuff i'm going to save that right now before i write my script and check advanced because i need that script box notice that it automatically puts in snc internal because i have that i think it's explicit roles plugin turned on let's go get the third script in my story that's my acl i return the variable answer gs.getsession.getclientdata program manager they're going to be true false or null if i forgot to set that synchronous thing so that's all i need because it's already saving it to the right data type watch this i love this unlike properties that always come back string even if you set them to true or false or an integer or something i get the right type here type of that says it's a string all right it just made a big old liar out of me well that's unfortunate but i believe that it will still work all right here we go we're going to try this with the rolling without the roll and make sure that works this is going to simply say yes you have access no you don't this is read access let's save that i'll make a quick write access script for the same thing oh i shouldn't have admin overrides pardon me let's do that because i do have admin rights i don't want to overwrite that not for this example anyway save my read without admin override glad we caught that otherwise i would admit another set of testing we'll make a right one insert with roles done go back to the list list should have two new roles go back to the list fine be that way can i get it here let's see oh never mind my browser history would take me there program access controls here so there's my two new acls for read and write let's first make sure it works like it should log out we'll log in with the role put the chrome message away once again and go to my program table being able to spell program this morning seems to be a challenge with me go to my table and yes i have read and write access to that field let's go take the role away creation me edit roles and take out that role out plug in and one more time let's try this should still be in my history for program iff no field so the acl is working as it should let's check the system log because i did put in a couple of things i put in that gs info message that was telling me about that uh never mind about that crazy report stack no idea where that's coming from i'll track that down at some point here's the info message from my login script action here is the user id here's the society and no chuck cannot read that if i were to look for more of them that started that way i would find them but that should give you a little idea of what get client data and put client data are used for just creating these session variables that i can use all over the place again i this is just scripts background and it's going in and saying it's not authorized let's try that again with scripts background dot info ps.get session don't forget that part get client data program manager i'm so sad i thought that was an actual boolean i want to try it one more time type of so i guess we're back to the uh ooh we're back to the part where if you want a real integer you have to do a parseint if you want a real boolean you're going to have to compare it against truth that sort of thing that's that's very sad i thought in my earlier test that came out true but it seems to be working fine answer in the acl understands strings thank goodness just your conditional statements may not because false f a l s e string is actually a true truthy value watch the javascript series kids the um other methods in glide session are pretty straightforward i'm going to back that up so to show up on the right i've got get client data that i showed you get client ip handy if you want to know what the client ap address is you can see it in that login script so hopefully i've got my firewall set up strong enough but it will return the clients maybe that's useful for you if you want to keep that ip address around for whatever reason say hey where are these people coming in from you may have a script that interrogates the range and says i'm only allowing this application or this functionality to run in this ip range or from our corporate firewall or whatever might be one way you can lock things down with using that put that value into a client data variable and now you got something right current application id brings back the sys id of the current application let's just go and test this real quick i am going to go through these fairly quickly if i go to the i'm currently in this cls 323 app you can see this up here in the application picker zero in on that i go to sys app.list and here is that copy this this id i'm not going to be fancy but it ends with 9619 that's my sis id of that if i do a gs.info gs.get session make that a little bigger for you get session dot get application id why is this useful he asks uh can i find function in fencing maybe this is not available in scope i'm looking at the scope one did i type it wrong get current application id o for shane they're not chaining these together in the expect format they've actually instantiated or created a session variable because if you're going to use it more more than once you may want to do that go back here put that in there tell me it was a capital d lowercase d okay just double checking i did copy and paste and look 961978 that's my why is that important because your application may want to know at some point what application scope is being picked i haven't found a way to set that application scope somehow studio does it and i want to know how because if you're running for something from a service portal for example and you want to make sure that that user is in the right scope maybe it impacts the way that functionality behaves or the workings of how you anyway um it came up once and i said oh i can't do this i had to go back to the standard ui then go back into service portal and it got to be a little crazy so i'd like to know if there is a way i don't see it in the glide session window yet get language tells them what their current language is in that two character format you've probably seen this in the system properties or if you've installed any i18n plug-ins you'll recognize these en for english es or spanish you get the idea the session token i really don't know why this would be useful but you can get that too down here in the session token look at that monster it looks like two societies put together time zone you want to find out what the user the current user session time zone is you could do that as well there are very similar methods directly attached to glide session you may be going well i use gs. something else that does the exact same thing that's fine and you can use that they do the same thing and i suspect underneath the hood at the java layer they're probably calling each other and this is just one way to expose them as a family of apis so you will get the time zone as the format that you see like in the system properties and whatnot get url on stack ain't that a happy one okay this is very similar to the glide uri api which i will be talking about in the future from whenever this is recorded september 3rd you can get all these lovely parameters i would not approach it this way i would use glide uri the way it's supposed to in fact i'm working with the docs team right now to improve the documentation around glide uri and glide action that's a fun one too that has been long overdue so watch for those real soon i believe we are retrofitting the docs all the way back to london with these updated documentation changes because the apis really haven't changed here for a long long time is impersonating yet this is one of those ones where it says you can use gs.getsession is impersonating so if i were to use the impersonation i could check it in a script there's also a gs dot is impersonating that again does the same thing underneath the exact same functionality just return me a true or false to say is this user currently impersonating you may want to detect that in a script somewhere to maybe present or not present a ui action say look you're or or hey you're impersonating i know who you're really supposed to be so here you can have this ui action because i put this in the condition statement uh what happens if a time zone is not added to the instance it will use the system's default so there's always a system default and i believe it's u.s los angeles america los angeles or u.s pacific that's just sort of where the company originated so that's the default default there will always be a system property for the default time zone if the users override that i think we did a time zone thing on tech now quick tip craig did it a couple of years ago so go check if you want to know what more information about that as i didn't get ist in my list i needed added to that list there is a list of properties that you can there a property of the time zones that you can manage because if we put every time zone in there there's something like 52 time zones around the world which is crazy when you think there's only 24 hours in a day but there are a lot of places that have special offsets ist being half hour off from those around it and it is one country in all one time zone so go look for the time zone property that says what should be in my list and you will get the right time zones in your picker for the users for the system property that kind of thing good question is interactive is another one that's also available from glide a glide system gs dot is interactive behaves just like gs.get session is interactive very useful if you want to know if it's being used by a browser or a rest api you may have data coming in from people putting it in a form you may have data coming in from someone using a scripted rest api or table api or something else and the business rules and everything else that needs to run needs to determine why would you why would you care well you may be constraining values or you may be running business logic only for the interactive users i had this when i had a bi-directional i built a homemade bi-directional interface that sent an outbound rest message to a third party which always triggered a web hook so if i did my changes on that app it would say web hook and say oh chuck changed this and then the instance would no we go oh good i'll update that record well if i did it on the instance and it sent a rest api to the app it would say chuck sent this well now i could potentially have this circular thing that say oh servicenow updated this oh the third party app did it servicenow and they keep telling each other i had to break that somehow and say look only send the outbound rest message when you are doing this from a user if it comes in it means we're both in if it comes in from a an api the arrest message don't send that outbound message so i had a condition on a business rule that said was this record updated interactively if it was great tell the third party system if it wasn't well that's the third party system telling me it was updating so you could use this is interactive method very creatively depending on whether it's a system talking to the instance or a user talking to the instance this just says is it a human is logged in this all the time on service portal menus very handy again available as gs dot is logged in i'm not sure why you would want to go through the effort of typing the extra characters but if you already have a variable set up fine you can do that it's just to say do you want to show this particular thing when someone's logged in in the case of service portal if someone's not logged in you're going to have a you may have a menu option up there that says profile no i don't want the profile menu to show up so you put in the condition of your service portal menu gs dot is logged in and it will say only show this if you're logged in right if you're not logged in you don't see the profile menu option if you are then you do that's the way it should work right so that's a that's a real fun one and then finally what we already saw put client data store something in memory that i can pull back later with get client data and do that interaction is session variable object also available on public sessions say public portal page uh is the sub if it's if i want to make sure i understand you right you would need the server side you need the server code on your widget to be able to pull that in and and look at that so yes short answer is anywhere you have server code you can get these session variables you can set them you can get them so i would approach that issue of maybe you want to set something like i did on login again caution caution caution about running synchronous script actions but you trigger off the login event you set that variable you set that session variable in a script action and then it's there it's it's available to any script that wants to use it so a server script in a widget could make use of that and say behave this way if this session variable is that way or you could set i wouldn't use well i'm not going to get into that that was a server service portal thought that just went through my head and i i retracted it as i said it so thank you world yes question server-side uh anything else in which techno session did we discuss time zone uh i don't recall let me type that into the chat real quick and give you the link to the holy directory of tech now episodes it's bitly slash servicenow tech now and if you look for time zone in there you should be able to find them andre said how does the impersonation affect the acl does it create two logins when we impersonate someone and log in as ourselves again when you impersonate you take on the rules and behaviors there are some exceptions that i don't recall what they are offhand but acls are evaluated as the person you are impersonating that's one of the best ways to test your code against other personas let's impersonate this person who has no rules let's impersonate this person who has itil role make sure that the acls are behaving the way they should and the scripts are behaving the way they should and that's that's what impersonation was originally designed for is you could do your testing by impersonating that so short answer there is yes all right i am winding down make sure to check my notes that i didn't miss anything we talked about some of the other methods available like is interactive and is logged in we talked about that summary it's summary time let's do this way oh that is not where i wanted to go i hate it when the wrong app is affected make sure it turns something off that it shouldn't have turned off summary time if you like you can use glide session it's directly effect available from gs.get session the docs page is right behind me just look for glide session scope or glide session global it will tell you all those wonderful things and some code examples on how to use them great way to set session variables which are yours to do with as you wish manage them have some standards around that the not sure where my cursor went after that i lost my notes here they are i want to make sure i don't forget anything for you as i pointed out avoid glide record lookups in those acls that's just going to slow you down session variables could be a good way to work around that or to improve your performance so if you've got performance issues that might be one place you want to look who has been using especially if you inherited the system from somebody else go look at the acls and find out where you might have glide record queries in them and use those session variables across your apps or processes as a way to set something in memory and make kind of a global variable i don't know that i'd i don't know how to update them all that much but it certainly can help save a lot of lookups as we go forward kevin's saying turn it on turn it on i got the wrong app all right we're gonna conclude then and uh next episode as i mentioned there is no show on monday the 7th because we've got a holiday here in the united states i'll be off for that coming back to you a week from today on september 10th with dictionary attributes there's some interesting stuff again that i randomly learned and went hey there's some stuff in here that i've never done before we'll show you the basics about what they are and how to set them but there's some interesting bits that i don't want you to miss that's that's what i want to bring to you is i never knew that before i want you to learn something on every one of these and if y i don't teach you something you have the challenge of teaching me something which how about that i will see you again in one week if not sooner everybody have a wonderful weekend stay safe if you've got your questions go over to the community again like follow subscribe to this video do what you want to do for now i'm chuck tomassi and until next time thanks again hope you have a chance to learn share and help take care [Music] you
Info
Channel: ServiceNow - Now Community
Views: 1,866
Rating: 5 out of 5
Keywords:
Id: RAgOmnru21o
Channel Id: undefined
Length: 54min 36sec (3276 seconds)
Published: Thu Sep 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.