Your cart is currently empty!
Part 12: Creating a Deck List Page
This is just a quick update – Iโve been doing some cleanup work just getting the data creation activities for Matchmaking and Game Instantiation working. ย I realised that I only had a couple of Decks to play with, so I wanted to get a quick and dirty deck list page into UI Builder.
This is really ugly for now, but itโs mostly so I can get testing and navigation sorted out.
I created a new page from scratch, set a Page Parameter for the userID of the player, and defaulted it to my friend Abel Tuter.
I then added a list component, and created Modal so I can create new Decks when I click the New button on the list.
The modal has an input field for the Deck Name – thatโs basically all I need for a deck – A name and a Player. ย I create a Client State parameter for the Deck Name which is set whenever the input component is updated so that when I call an event from my โCreateโ button it can pass the deck name to a โCreate Recordโ data resource.
The Create Record data resource is interesting – all the attributes to create the record are passed in the event handler, so I passed it the User ID from my context properties, and also the Client State Parameter with the deck name. ย I set the table to be my Player Deck tableโฆ. this successfully creates the record:
My next challenge is trying to redirect to the Deck Builder interface that I built a while backโฆ I need to get the sys_id of the newly created record from the Data Resource. ย This proved to be a little tricky – I could add an event handler to the โOperation Succeededโ event from the Data Resource, but the lookahead didnโt bring back any of the content of the payload that I could use. ย I got some advice on the SN Devs Slack channel (awesome resource) from the ever helpful Brad Tilton who suggested writing the payload to the console log. ย This meant writing a tiny client script, but because this is for debugging purposes Iโm not counting it towards my โno codeโ challenge.
Once Iโd written the payload to the console I was able to spot my SysID nested very deep in JSON schema:
This gave me the path of @payload.data.output.data.GlideRecord_Mutation.insert_x_168987_flow_de_0_player_deck.sys_id.value which is a mouthful, but it returns a sys_id that I can use.
I could then add an event handler to โlink to destinationโ using this path once the newly created deck has been added. ย
Comments
2 responses to “Part 12: Creating a Deck List Page”
I was just able today to get my deck fully displayed in the play space and when I click a button create a new deck that has the cards all randomized. This way I have created the randomized deck. Now I just need to figure out how to only have a certain amount of cards on the screen instead of the whole deck! I find it funny that we both had to debug to find a sys id. I found this guy named Jon G Lind in the forums that had an AMAZING tutorial on finding sys ids of newly created records. I hope that I can get a little bit more out of these blog posts because I am coming to the end of them. Thank you so much for these!
I’m really glad you’re getting a lot out of these blog posts! I’m super busy at the moment, so I haven’t been able to update with any new information about how I’ve progressed but I fully intend to get back on it and maybe also produce some video content covering the talk that I did at Knowledge. It’d be really interesting to see how you’ve progressed with your own game too!
Leave a Reply