Super cool feature ‐ setting catalog item variables from URL - jcmings/sn GitHub Wiki
On one of my recent projects, I worked on a record producer. This record producer had a lot of mandatory variables that needed filling out. This makes the user-experience of actually using the form pretty poor. And so, in an attempt to fix the user-experience, I set up a way to auto-populate the majority of the fields through the selection of an earlier field. In other words: the user answers question 1 and questions 2-x get auto-filled. (I did this using GlideAjax... which I conveniently have written a post about).
And that works great. Full stop. But it got me thinking... what if I could send someone a link with question 1 (and therefore questions 2-x) already answered? For my particular use case, the user is supposed to initiate the record producer via Virtual Agent. Essentially, the user chats with Virtual Agent and then Virtual Agent links them to the record producer. And to create a positive user-experience, I needed to ensure that if the user specified the answer to question 1 to Virtual Agent, they didn't have to do that again once they got to the form.
And so the research began! After doing some Googling, I found exactly what I was looking for... Enter The SN Guys. They posted the solution I was looking for: setting catalog item variables from URL parameters. By retrieving their update set and adding a variable set onto a catalog item, you can now load catalog items with pre-defined values. This is beyond useful; for example, you could conditionally display different catalog items with different options pre-loaded to different users.
Everything you need to know about how to use the tool is located in the post linked above. One thing I will note: if you are passing a URL through Virtual Agent, you may run into trouble if you include the {
or }
characters in the URL. If you run into that issue, I'd recommend encoding them. (The post outlines what this means, but if you're stuck, you can basically use something like this w3schools HTML encoder to convert characters like {
into %7B
.
If you're reading this post, I would encourage you to check out what the SN Guys have built. It's a game changer. I know this Github wiki of mine isn't even indexed by search engines, so this probably isn't an effective advertisement for the tool... but we can consider this post a time capsule of appreciation.