Virtua agent : vaSystem.switchTopic('Topic name') not returning back to previous topic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2023 12:03 PM
Hi All,
I am facing below issue when switching topic from one to another.
In "Topic 1" based on yes/No question switching topic to "Topic 2". System successfully switching to Topic 2 but once everything completed its not returning back to previous topic. I have tried below code but no luck. Can anyone faced the same issue and is there any way that we can resolve this issue? Kindly provide your suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2023 12:47 PM
Hi @Rani11 ,
I trust you are doing great.
After successfully switching to "Topic 2," the system is not returning back to the previous topic. I can provide you with some suggestions to resolve this issue.
One possible solution is to use the following code snippet to switch topics:
vaSystem.switchTopic('Topic Name 2');
owever, based on your description, it seems that you have already tried this code without success. Another approach you can attempt is to set the global search text and then trigger the topic discovery. You can use the following code snippet for that:
vaVars.global_search_text = 'Topic Name 2';
vaSystem.topicDiscovery();
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2023 10:39 PM
Hi Amit,
I have tried both but no luck.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2023 12:18 PM
Use vaSystem.switchTopicById(sysid)
You shouldn't use vaSystem.switchTopic() - and vaSystem.topicDiscovery() was a hacky workaround to avoid that which you also shouldn't use to switch topics (if you know what topic you want to switch to).
From Virtual Agent scripts (servicenow.com)
vaSystem.switchTopicById(sysid) | Enables the user to jump from the current conversation topic to the specified topic ID. The X button is available, so that the user can end the conversation. After the topic ends, the user resumes the global topic. When the conversation ends, the user can click to restart.
The optional resumeBehavior parameter specifies how the conversation flow resumes, as follows:
If resumeBehavior is not specified, the default behavior for the instance is used. |
resumeBehavior is a new parameter to Tokyo (I actually just learned about it getting you the link to it) - I've never used it and by default, if you omit it (i.e. just do vaSystem.switchTopicById(abc123)) it'll resume the calling topic which is what you want.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2023 12:22 PM
Hi there,
Pre-Quebec to switch between topics, a method used was "vaSystem.switchTopic()". Although this method does perform it's basics, it does bring unexpected side effects on the working of the Virtual Agent client. Starting with the Quebec release, it is recommended to use "vaSystem.switchTopicByName()" or "vaSystem.switchTopicById()" instead.
Replace the usage of "vaSystem.switchTopic()" with "vaSystem.switchTopicByName()" or "vaSystem.switchTopicById()".
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field