Building a Board Game Management App in AES - Live Coding Happy Hour for 2021-09-10

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome to live coding happy hour this is friday we're back to fridays all right let's go around and do our introductions first uh we'll go alphabetically i guess my name is brad tilton i am a senior developer advocate here at servicenow i've been developing on the platform since 2008 and i'm excited about today's show uh earl hi everyone i'm earl gk and i am your dungeon master this evening go ahead and please roll for initiative chuck it's your turn ah i rolled a one i have no initiative this afternoon but you know good thing i have a plus four initiative because then i don't feel like such an idiot wow we are we are down here my name is chuck tomasi i've been on the platform since about 2008 i was a customer for a couple of years and i've been with service now for 11 plus years so we'll just go with that so it's good to be here and what are we doing to oh we have to go do our beers now too brad same order drinks i'm still going non-alcoholic with the odual's amber and i am going through more of our collection i have not done a single episode with just be here uh so i'm still continuing i got buffalo trace kentucky straight bourbon whiskey and i'm gonna do on the rocks today all right and i have i believe this is my last bottle of dragon's milk so in celebration of dragon con last weekend uh which i swore i'd never drink again i lied cheers what are we doing today brad all right uh today uh we're gonna we're gonna try to uh solve uh part of a uh problem that i have at my house with my board game collection uh so i uh it's hard to find different board games because we did a thing where we took them out of the boxes and put them in bags and all this stuff and so they're just all in this closet and my kids will take them out and put them back wherever and so it takes me a long time to find one so we're gonna do some board game collection management uh and then i also want uh to be able to give the app uh some uh you know some some metadata like i want to tell it i want to play a game with three players uh and the youngest person is let's say nine and i want it to give me i just pick a random game for us to play we're going to try to do all of this in app engine studio i think it can be done i think it can be done too or or we would have picked a different topic this app will speak to me in many levels but this is this is very similar to customer use case you know they've got various things around the office that they need to keep track of so easily adaptable use case all right well i'm going to go ahead and share my screen right oh move mouse now got it on zoom i'll watch youtube and let you know if there's something wrong i may have forgotten for two seconds that i was also running production um there was a a half a second um transition salinas there we go looks good all right so this is a servicenow instance uh if you've never seen it before which would be strange if you're watching the show so we're going to start in app engine studio and this is a pdi which is a personal developer instance if you want a personal developer instance you can go to developer.servicenow.com and request an instance on rome or quebec or paris still all right so we're going to go ahead and we're going to create an app to manage board games so i'm going to hit create app and [Music] i'm going to call this just bg uh we'll see if this works i think you need a graphic like a piece from sorry or a dice or something oh that's a maple time meeple time yeah we'll we'll put a graph meatballs i need to open my beer all right so we have our app created i'm gonna go to the app dashboard can i change the name of the app from here yes yes so i wanted this app scope and now i'm gonna change it to board game well played oh that was a play on words i realized when it was coming out of my mouth all right so board game management so i need a few tables in this app the most obvious table is going to be something to to track all of the games and then i'm going to need we're going to have i think a table like a request type table where i'm going to create a record and then it'll kick off a flow and then it will put something in the record saying here's the game um so do that and then there's one other table that i wanted uh what was it i have a spreadsheet that i'm going to import but i think i want to create the supporting table before i import the spreadsheet so that it gives me some records in that table there we go could have had the spreadsheet open already but that would have been would have been too good uh we're going to i want a location so in my game closet i have a bunch of bins and i want to know uh which bin uh is the game is in so phil wants to know am i gonna create any tables with a plural name do i do that a lot i hope not try not to i'm just going to call this location and then sure let's number it all right so we're going to create this location table i'm just going to give it a name and then i think a parent field so that we can make it hierarchical so we'll give it a name and then we'll say that's just a string field and we'll make it 100 characters because why not i'm going to make that the display value then we will add another field called parent and this is going to reference this oh the table doesn't exist yet huh yeah i was going to say what how do you envision a parent-child relationship with the locations well i was just going to make it hierarchical so oh okay kind of like we do with the yeah with the group table the location where you've got it's somewhere in north america and then um let's do this so this app could be a multiplayer game it's brad's first board game house and his second board game house and then the board game closets within uh why can i not pick this table uh it doesn't matter we don't need we don't need that field yet anyway all right we'll put it on a form designer later yeah we'll we'll add it later so now i am going to create a table from the spreadsheet and [Music] it's this one you spelled board games wrong right there now this that's amazing because i created this from a spreadsheet that earl sent me of all of his games and i went through and picked all the ones that i had and so this is basically the uh this is the subset of games that earl and i both have do we have that significant of an overlap there is a significant overlap i added mine but i think there's like 40 games in this list dang we have you uh so let's continue it's gonna prep the column headers for us so i like this uh i like this step where it's gonna guess what uh what column headers i have but uh it's not going to uh but i'm going to get to edit it beforehand there we go i thought there were more than that so we have minimum age and i think a lot of these were from board game geek so location is one so for location i need a reference to the location table yeah i'm going to change this to reference and then the reference table is going to be location max players is an integer cooperative is a true false min players board game geek id i think that's a fine field is that a number or should it be a string it's a number okay i guess we could make it a string just in case they change things on us uh yeah you're not gonna be doing any calculations on it yeah that's true um yeah uh playing time is an integer duration or an integer or playing time in what seconds minutes it's in minutes yeah yeah okay so all right cause you got this from board game geek yeah uh so we'll call this we'll just call this game and then i don't know that we need to number it i don't know that you need a number either there we go go fetch me game number 1016 go fetch me game number 1016 person number 402 start referring to your kids with their society number two all right so let's say done uh i like the uh the idea map of the shelf uh included using using the map uh functionality when it gets re-platformed i like that uh so let's go ahead and take a look and make sure that our data got imported uh we do have a good amount of data in here 48 and then i put these locations in here it's been a through e uh if you saw the picture of my game closet you know that it's not actually that organized on the s dev slack but uh there we go i could see this table also having a parent because uh expansions yeah yeah so i uh i just kind of uh included like the expansion as a separate game but it could definitely uh definitely do that um or expansions could be a related list to the game yeah because it's not likely that you're going to take an expansion from ticket to ride and add it to you know katan or something that's true so let's go ahead and do a little bit of form design this is a good time to do this step um i like dennis's query get game where user id equals dad and wins is greater than one i don't want to play anything that i lose all the time let's put all mine wait where did i just lost my query would be more like get games where learning time is less than an hour that is a good one yeah i can do an entire episode on just teaching how to teach board games quickly all right let's make sure everything moved around okay and then oh our previous gun let's open something up in there uh let's say seven wonders it is two to seven players nice classic all right so i do have uh playing time in minutes for the duration let's uh let's just say change the label yeah we'll say minutes min is also used in other contexts all right i think this looks pretty good yes because i could misconstrue that as the minimum playing time this is going to take you at least three days yeah oh yeah all right so game location the other table that i want uh so what we want to do now is i have this i've got this game table and it can be hard to make a decision on what game to play and it sometimes it's fun just to pick a random game so i want to be able to tell it hey i've got um oh yeah i you know i've got three players and the youngest player is 10. so i want you to look up all of the games that meet that criteria and then i want you to give me one of them so i don't know what i would put as the average duration of chess bill oh yeah or uh depends on who i'm playing yeah a d campaign can go for years uh so what do we call this one uh suggestion maybe or table names are the worst let's go suggestion or okay uh we could call it game picker no let's just go up here now is this rome that you're using right now brad this is rome so this is the current version of app engine studio that you can get and there will be a new version coming out on ga day so next week i believe it is next thursday uh so we want to track what do we want to track here uh we want the number of players it's going to be an integer not an integer and then we want uh min age i'm curious how you're going to connect this up me too no i have an idea would it be age of youngest player would be more descriptive yeah we can change change the label i like i like short field names and then long labels not too long of labels yeah i've seen people really overdo it on labels sometimes and then i want to hold so let's just start with the number of players in the age and then i want uh play time maybe as an option um we could do playtime uh game that's a that's a reference to the game table and then yeah let's let's start with this and then we'll think about uh the other ones uh i probably want a display value but i'm not sure what that would be for this record oh let's give it a let's give it a number field there you go cause this is basically a request isn't that in the properties though the auto numbering uh can you get to it after let's find out because you're still going to have to hook up that little javascript the auto counter thing at record number that's interesting pick sure all right did it give me a number field yeah i did add a new column i bet if we refresh and by default that'll be your display yeah so let's see number oh you can be explicit about it but it the way that i heard the story is anything with number name you underscore number or you underscored name will be a display value nice don't ask me what happens if you have both what happens if you have both um after people in the universe disappear all right so what i want to do is i want an epic catalog item which is actually a record producer who needs thanos we've got kovid [Laughter] pick a game uh define your parameters and get a game i don't know so let's edit this all right item details there we go so i want this to be on the picker table let's put it in the service catalog sure put it in the hmm how can we help you voices can we help you yes okay that's like the generic place i always put it if you need a game you need help all right so the first one is going to be text i think that's right hey come on subtype there we go uh no we want to know do we have nope well that's unfortunate yeah that confuses me still it would be a text with a validation yeah maybe we can go i think we can just change this variable on the back end if we have to so we're going to connect this one to um so where do i tell it oh here it is um who is the youngest player yeah what is the age of the youngest player there you go you're missing an a it is going to be mandatory uh i do like the little preview over here and then do we need any additional text validation hey there we go there it is that's still strange but sure maybe it's to not overwhelm people with field time that probably is it um somebody might not know what a what an integer field does all right let's add another one this one's going to be uh how many players yeah so players how many people are playing we'll make that mandatory and we'll go to additional details and we will give it number again [Music] and how much time do you have let's start with these two and see if we can make this work okay uh okay so let's go to settings and see if there's anything in there um yeah i don't need that i don't need that access i think there's any user there we go yes we are going to use a flow oh spoilers that's where we're going next all right this looks good let's submit i'm just trying to think of i've seen anything that has to do with random inflow i think there's a data pill picker for math.random and i think you figured you knew where you were headed with that i actually didn't check so i think there is this part of the app could come to a screeching halt that's super after tradition on the show well you you you simply said let's see if we can do the solid app engine i did say that yeah you didn't say we were going to i generally uh i generally don't uh over commit to things i i under commit all right so we're going to run this flow when a record gets created in that picker table and then we are going to try to do a lookup on the uh i'll say created uh oh i wonder if we want to let's say created or update well let's start with created i may want to change this because if you don't like the game we may want to have it redo it pick a new one but let's let's see if we can make it work first all right so now i want to look up all of the games that that meet that criteria so this is kind of our first so we want the game table and then we want minimum age is these are greater than greater than or is there it is just above between oh i think this one right greater than oh that's comparing it to another field oh you're right yeah just above between there it is and then we will grab min age and then the other was number of players uh so so we're gonna do two of these men players is this is also going to be greater than or is i think sounds about right i hate it when you get the logic backwards yeah and then we want max players less counter is less than or is and then we don't have an active field or anything so i think this is all we want so i'm going to save it and play yourself um those two aren't going to be mutually exclusive are they the main players so let's let's uh test it uh so let's go ahead and we'll filter the data yeah let's create a record in this table so players let's say we have four players and the minimum age is eight that should return us some stuff test all right and then let's get some results pick up records how many zero no not good uh so men players is greater than four and max players is less than four that's that's what i was wondering about that condition doesn't make sense it does not make sense i don't think you need the max players though oh wait you do oh is it the other way though so we want minimum players to be less greater than multiple yeah and then max player yeah look at chuck with the foresight that's because i always get it wrong uh if i change so you instinctively think oh i should reverse this yeah pretty much uh here let's just refresh that's usually i want to go running for the main list and do a list query first and then figure it out from there all right yeah when are we going to get a paste encoded query yeah you figure it out designers yeah paste paste encoded query because that's something that every low coder will do all right so we just want to change this to less than or is you knew it was going to be that yes yes any time you fiddle with it it gets mad and says nope start over all right so chuck guarantees this one's gonna work i didn't say that i said the other one looked funny like you i don't over commit i guarantee it 1000 records hey 40. that's uh the majority of your libraries yeah i mean four players over eight uh all right so we're working so far we think let's get rid of that one all right so now what we want to do is we want we do you want you want to think this one through yourself right or do you take inspiration let's think let's take some suggestions so we what we want to do ultimately is we want to update the record with the name of one of these games that gets returned here so i think we need to get we need to get a flow variable to store a number between one and the count of your first step right that seems right yes so um will we call this random choice is that a good way to name that no i can't remember what what's expected everywhere anymore if there's a label it usually means you can go with human-readable all right so we have random choice and now we need to populate that so where's my so what is the flow variable thing called i guess i could type the word variable is it in flow logic like i said logic yeah i think oh yeah that always fooled me because i tried setting output variables on a sub flow one time like where is it oh so where's the transform where's the transforms well we'd have to we have to give it a value and then we can transform it so what if we give it i don't even know is this gonna work maybe math no there is no random i thought there was oh huh i thought in rome there was random or was that or did we ask ask for oh you know what during one of our creator toolboxes on transforms we ask is there going to be a random and they said yes in a future version that's probably what's future now uh six weeks ago sam says code uh i think we're gonna have to code a quick uh action right is there another way in action or you just do the you just do the scripty field thing oh yeah that's true is there an no code weighted low code way to do it you know what we're still in aes so even though there's code yeah the challenge wasn't to do the challenge wasn't to do only really good pretty thin there brad uh so let's say what's the uh come on game count was fdata dot um look up record records dot count said there's no value or anything yeah i i i get the heebie jeebies doing that i like to put a parseint around it yeah pretty any time any time you pull out random end data all right so math random i don't remember how the random what the random function takes uh var i think it just takes a seed doesn't it and then you multiply it times the count plus one no doesn't it need a like a low end and a high end and then you're going to get a choice back but what are you picking from we didn't store an array of sis ids or anything it would be um so you times math random uh by the the count minus the minimum which is one and you add the no yeah just by times it by the mac the account i think yeah times game count yeah yeah that should be enough yeah you're going to get back a number what are you going to do with that game count is going to be 40. so we're i'm seeing 40 by math random then what are we doing so it's going to be more than 40 at that point right here we go no it's not going to be another 40 because math.random returns a number between zero and one sam says uh he has oh you did the math.floor thing right yeah but where does this plus one is if you want one through 40. otherwise this can be zero through 39. the question is what does that random number correspond to you didn't store a list of games that were returned well we can uh oh so because when you do the lookup records can't you um select a record using that number i think we'd have to for each through it and then i think you're gonna have to forage through it and create an array well we could just do an if statement in the for each and say is this are we currently in the oh right because you did your look up but you didn't do your for each yeah yeah we haven't for each yet okay so what's so good you're going to retrieve 39 records to get to that 40th one it's you just gotta put math um put all of that inside of a math thought floor okay and you you should be good all right so we're gonna turn it done don't forget to return it oh yeah you're gonna need another variable another flow variable another flow variable to count which one you're on this is one one beautiful record let's call it uh yeah as we don't have ten thousand people doing this every ten seconds we'll be fine uh can i give it a default value [Music] i believe it defaults to zero but you could also do a set flow variable zero outside the for each loop uh can i set multiple float value variables in here no i see a plus up at the top of that list do that again it does say set flow variables plural open that up again oh yeah there's your plus so andrew says to set it to the count and then count down which is also good because then we loop through well it doesn't we don't necessarily live through less at that point right no but you're using one less variable and i don't know that i want to mess with the count yeah it's true don't mess with the count i'll throw down no let's go game iteration is zero all right there we go now this this should work where's my so we'll say if game iteration is random choice then we're going to update a record and we're going to update the trigger the trigger oh he was saying decrement your random choice variable not the count that would work too [Music] and then when it gets to be zero you do your record update uh and we're going to say the game that would actually be more efficient brad because then you're not going to well it's still going to do a for each on all the records um we could do an end right yeah the game record yep um and then we're done put an end on that no i think your flow ends at that point that's a do not pass go do not collect two hundred dollars because it's already doing it yeah you need it the way it's designed now we still need to increment the flow variable oh right for the else yes yeah if you were doing andrew's method um no we would still need to document it yeah but you could decrement it first oh that's true oh wait no then you'd miss one wouldn't you i know i mean if you change the the variable count to be one more then you wouldn't well like you said when you when it gets down to zero you're there you're done the loop is over you're not really comparing anything but the question is do you decrement first wow how do non-computer science people figure this out if if we can barely figure it out it's called a youtubing live coding happy hour uh try it until you realize hey i can never seem to get that first game right i think that's it dude i think that's it yeah so we'll try this and then if it works we just won't mess with it anymore we'll move on no we should one test is not a test suite especially if it's the first game or the last game of the list yeah if it comes up as blank you know you're in trouble right so your test is finished running examine those variables first party uh oh oh it never ran the update record oh on that one yeah so is that on the first one so what's the what's the it's updating on every record uh game iteration no it's not what's that what's the what was the set flow variable for the right there it goes there it is can you examine i was looking here can you see your flow variables in here um [Music] on step two can you click on subject yeah does it tell us yeah what's random choice can you click on step two here yeah oh yeah nine there we is nine okay so it updated on iteration 10. so inclusive i guess zero through nine one through ten sounds about right to me and it was updated with game which game uh where are we update record with game record sis id do we game is oh we only know the sys id so let's go look at the record all right let's give it a let's do another one uh here let's try to do this using the uh catalog item what a coincidence it shows ticket to ride when that was the one i talked to chuck about on breakpoint all right he's got a chicken to ride let's do this from the catalog and see what i get can we help you sure did you activate that flow i did not how many times have we done that the answer is yes yeah it's activated see [Laughter] maybe it's still spinning all right it's activated successfully uh what do we call this pick a game all right what's the age of the let's make it uh older this time and then we'll say six people are playing this is a tougher tougher you got something let's admit we're here and flowing around hey that one can go up to eight players so let's let's make sure that this uh fits so minimum age is 10 max players is seven so yeah man players is two it's going to take us 40 minutes guys hey it works all right it worked do we want to go back and try to uh optimize this i wish there was a way to harvest it just random yeah to just tell it hey in your set give me the nth record i mean we could do that with another little script but this is mostly no script oh now do you want to um pull in the location of the game into that table too um because if you're trying to go for the full user experience they should be able to see it right away from where oh yeah see where it is yeah let's do that uh let's look at that picker table i have a there we go oh so you're gonna copy in the location value uh i guess we could just use a derive field but can we yeah let's see can you just display a dot walk film not with form designer let's go form layout that'll do it dot walk through game i'm gonna move this around a little bit we don't normally show this to our low code audience there we go it's in bindi bindi all right yeah so this is our little picker app it works took us about 40 minutes it was truly low code we did what three lines of script yeah one of them was just a value return and it was against our willow yeah i'm still my my wheels are turning trying to figure out how we could have done that a little easier but it's all right every everything i think in my head just involves okay maybe just two lines of script oh maybe just one line of script like if you there can be a default value created on record creation and then just pull from there but then let's just you would script that too yeah i think if if you truly wanted to make this um you know scriptless you'd have to pre-bake a custom action that takes a a number and returns a random from that yeah i think this is uh this would be a good um you know that that could be a good candidate for contacting your you know your resident pro coder and just hey can you create me a 10 minute action that gives me a random number between two inputs the other oh the other thing if we didn't design it to be so we have that we already have the function of picking a game but we could also display all games that fit the criteria yeah so one of the things that i had thought about was a related list that would show yeah all of the games that fit the criteria so then you could kind of look so you end up with like a midi to many table that gets populated based on the 4-h we could do that or you could come up with a not picked table that was related that had a parent record of picked that way when you see what's picked you'd see all the other ones that are not picked yeah i mean this would be the same thing yeah yeah you could do that yeah so let's let's do a [Music] um game can you make an m2m through here i mean an m2m is just a table with a couple of reference fields yes and no a true m2m has a definition that tells the system what you can do because if you just do this you're not going to get an edit button on your related list [Music] all right we're going to do this to keep it in aes functionally this will work with two reference fields i'm regretting naming that table picker just in case anybody was wondering naming regrets that's never happened [Laughter] i don't know what you guys have been doing okay and then we may still be able to we get a an edit field and list control i don't know let's see no uh so it builds things this is just going to be okay oh it's this collection yeah this is just going to be informational for the most part though so i just want to edit our let's try it yep put in our else that we want to create a record where's or do i want creator update no where's my creator record i don't know why and we want this to be on my game game picker m2m oh oh i need to refresh probably oh yeah flow designer doesn't know do we have a i'm gonna go andrew barnes style and refresh the browser when aes kept on my tabs nice i don't think i realized that would happen oh it must be recording sessions all right let's go create record why can i not create a record in that table and that table was actually saved yeah i mean it shows up in the related list well that's true right game picker m2ms what's the what's the table name um oh the clock is against you no why is it the one that's not there here yeah close it and open it again yo i t try next i'm going to reboot and we'll see make sure it's plugged in i wonder if there's something in the background that is not liking that you put m2m in there you used up all your table licenses well i think we'll have to save that for another day v2 yeah i mean i think this is a use case we will be uh we will be continuing with all right i think you have a bunch of things we can add to this screen share like wait we can increment how many times it gets suggested record how many times it's played and then wait it weight the decision based off of what's been played the least that's true yeah so this app isn't even tracking like ratings or when you play it or um you know i we could do some surveys uh ultimately i want to do something that that like sends my kids a whole bunch of a bunch of notifications or something until they ding it's your turn no i just want them to put the games away i don't care about what they're doing when they're playing so a nice um extended task assign a task to them to put it away that's right yeah they don't they don't get to do something until they close the test he hooks it up to automation so that when you put the game away it unlocks the tv remote there we go yeah i like that oh what could we do there yeah or we we can uh integrate with the apple screen time stuff and shut down their ipad until they put it away i like it all right how was the beers did i go first brad how's your own duels yeah bio duels amber this is a pretty good non-alcoholic beer i'm gonna give it a four earl just about emptied that bottle oh it started it was completely full i would be on the floor uh i had a buffalo trace a whiskey bourbon um it's higher proof than what i usually drink so what is it this is a what is it 40. it's 45 90 proof yeah i think i usually sip a 40 but um and i felt it so uh it's a good sipping wine solid 3.5 all right and i've got one of my all-time favorites dragon's milk which is 11 and uh did not finish but it is also a sipping thing so i will be enjoying that for at least another hour and as per usual i give that a five nice also i want to point out that i've been drinking it out of a plastic cup because i i don't have any of my other glasses i don't i don't want to look like a college student drinking whiskey from a plastic cup no we're not unpacked yet i don't think anybody would have known that if you hadn't said it that's true that's the best part a wonderful thank you gentlemen good use case good stuff we learned a little bit and kind of got in a couple of hangouts but uh came through in the end so thank you everybody for watching do we have any announcements brad or earl that you can think of earl go ahead okay so um on the theme of board games and games uh if you are part of the sn devs slack community um a couple of weeks ago a few weeks ago uh in the gaming channel i asked if people were down to play some online streaming games together uh like party games and stuff like that as part of the community and just to have more hangout times uh just people to people um and now that i'm finally in my new location it can actually start setting up a lot of my stuff uh i think i'm going to officially start that next week so if you hang around the lchh channel or the gaming channel uh look at look out for any posts from me um i'm gonna aim for uh wednesday or thursday for our first uh community just game day game night depending on the time i know people are in different time zones so we'll probably do an early one and we'll do a late one depending on the week but i want to earnestly get that started because i know a lot of us are into gaming and just want to hang out um with other people that do like work so that you have a shared camaraderie but don't have to actually talk about it and there's a lot of value in that good stuff thanks yeah thanks earl um check we have a break point coming out next week we have a break point coming up next week i have recorded it and i will be editing it right after we're done with this coming up with dhruv gupta so a lot of people know him from the community and from meetups and lots of places the man gets around and that's what i wanted to talk to him about is is establishing that exposure and he's only been in the ecosystem for five years but done some really amazing things the um tech now coming up on the 28th is about iot and connecting that to service now so jeremy duncan will be leading us for that devlin.sn slash tn90 reg so go to tn90 reg and you can register for that as well next week is mobile week so we'll be looking at the new mobile builder that's coming out uh on tuesday morning u.s time creator toolbox and then we'll be doing some mobile development on live coding happy hour next friday and we'll have a blog out too with some more resources on how to learn about it uh so look forward to that good stuff thanks everybody see you next time everybody bye [Music] you
Info
Channel: ServiceNow Dev Program
Views: 449
Rating: 5 out of 5
Keywords:
Id: VBcnnAQD19Y
Channel Id: undefined
Length: 61min 51sec (3711 seconds)
Published: Sat Sep 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.