Reordering Virtual Agent Static Choice list settin... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Hi there,

 

While working with the Virtual Agent designer, at some point you will be using the User Input "Reference Choice" or the User Input "Static Choice". User Input "Reference Choice" is a nice one to get values from a table, through script, etcetera. User Input "Static Choice" would be used to list predefined choices available to the user. The annoying thing though…

 

How to reorder the "Static Choice" list setting?!


Choice List Setting

An example of a User Input "Static Choice" and it's list setting:

 

find_real_file.png


Re-order choices

Adding a choice to the existing Choice List Setting seems pretty straightforward. You just click the + sign and fill in the Label and Value for the new row. That's it! Though what if existing choices should be re-ordered? Through the Virtual Agent designer: No chance, forget about it!

 

Obviously when you are just added the User Input "Static Choice" recently, and the number of choices isn't that long, you could consider just removing them and adding the choices in the correct order. Though what if it's an existing Topic? Or a good amount of choices? Then just removing the choices and adding them again won't be an option. Removing an option could break elements in your existing Topic! Especially on larger Topics this can get quite painful.

 

Isn't there a way at all? There is actually! Not the most accessible one, and also not everyone will be capable of achieving this. If you could avoid this approach, I would! Though like I mentioned, in some cases removing choices and adding the choices again won't be an option.

 

So what way of re-ordering the choices am I referring to? Editing the "sys_cb_topic" record for your Topic.


sys_cb_topic, "Graph" field

The choice which we would like to re-order:

 

find_real_file.png

 

Now navigate to the "sys_cb_topic" table, and search for your Topic name. If you would view the XML of the record, or add the "Graph" field to the List, notice that your choices are actually mentioned in the "Graph" field. Just search through the code for "Display name of the distribution list" from our example. You will notice:

 

"03d7341e566e45a38bde8efb29acd769": {
      "id": "03d7341e566e45a38bde8efb29acd769",
      "name": "distribution_list_options",
      "label": "Distribution List Options",
      "varType": "choice",
      "choices": [
        {
          "label": "Owner of the distribution list",
          "value": "owner"
        },
        {
          "label": "Distribution list email address",
          "value": "email_address",
          "checked": true
        },
        {
          "label": "Add members",
          "value": "add_members",
          "checked": true
        },
        {
          "label": "Remove members",
          "value": "remove_members",
          "checked": true
        },
        {
          "label": "Display name of the distribution list",
          "value": "display_name",
          "checked": true
        }
      ],
      "category": "vaInputs"
    }

 

Indeed, it concerns User Input Static Choice which has been named "Distribution List Options", and all five choices are listed here. All five choices are listed in the order they are currently in! In theory, you could re-shuffle the order of the choices from here. As pre-caution I would export the record first (XML), and then make some changes.


The "Graph" field is editable for admin users. On both List Lay-out and Form Lay-out.

 

See below my re-ordered choices, I've moved "Display name of the distribution list" to the middle. Again, be really careful with this. A mistake is easily made! A comma wrong, etcetera.

 

"03d7341e566e45a38bde8efb29acd769": {
      "id": "03d7341e566e45a38bde8efb29acd769",
      "name": "distribution_list_options",
      "label": "Distribution List Options",
      "varType": "choice",
      "choices": [
        {
          "label": "Owner of the distribution list",
          "value": "owner"
        },
        {
          "label": "Distribution list email address",
          "value": "email_address",
          "checked": true
        },
        {
          "label": "Display name of the distribution list",
          "value": "display_name",
          "checked": true
        },
        {
          "label": "Add members",
          "value": "add_members",
          "checked": true
        },
        {
          "label": "Remove members",
          "value": "remove_members",
          "checked": true
        }
      ],
      "category": "vaInputs"
    }


Result

After saving the changes made, let's open or refresh the Topic in the Virtual Agent designer:

 

find_real_file.png

 

Notice the changed order of the choices! Eureka 😀. Don't forget to Publish your Topic.

 

Again I would like to stress be really careful with this. It's certainly not something for everyone, and if you can avoid this approach: please avoid it! Though there will be cases where this will be helpful because you might not be able to remove the choices on an existing Topic and adding the choice again.

---

And that's it! Hope you like.

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Platform Architect @ Quint Technology

2x ServiceNow Developer MVP

2x ServiceNow Community MVP

---

LinkedIn

Comments
Lynda1
Kilo Sage

Why not just click on the + of the second item listed to add a new choice in the 3rd spot? That seems a lot easier, faster and safer to do.

find_real_file.png

Mark Roethof
Tera Patron
Tera Patron

Hi there,

If it's only about adding a new choice, then certainly that's the best option. Though if it's reordering existing choices, that won't help. Then you would need to remove your existing choice first, which could break elements in your Topic. Especially with larger Topics this can be painful 😞

Kind regards,
Mark

Amie Macejkovic
Giga Guru

Thanks so much!  This is exactly what I was looking for!

Sam121
Tera Contributor

This solution doesn't work for dynamic reference choice list where i am looking up values from a remote table.

 

Regards,

Sam

Version history
Last update:
‎08-14-2024 11:10 AM
Updated by:
Contributors