- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 03:59 AM
Hey guys I am trying to create virtual agent flow that checks if user has entered valid incident number in query and then moves forward. The virtual agent script that i wrote on decision node is this, it isn't working at all. Please help me fix the script
Our logic was to build it in following way:
if user typed incident number, directly show him incident card.
if user typed generic statement like "show incident" then make him go through complete topic.
(function execute() {
vaVars.userInput = vaSystem.getSearchText();
var incidentPattern = /INC000\d{6}/i;
//var requestedItemPattern = /RITM\d{5}/i;
if(incidentPattern.test(userInput)){
vaVars.matchIncident = vaVars.userInput.match(incidentPattern);
return true;
}
else{
return false;}
})()
i
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:14 AM
@PriyanshuVerma1 any follow-up help needed? Or was my answer sufficient?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 04:09 PM
Where is userInput defined?
Do you maybe mean:
if(incidentPattern.test(vaVars.userInput)){
?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 08:40 PM - edited 07-23-2024 09:55 PM
Hi there,
Not sure, it might be usufull if you also for example share the error. Though just viewing the script, is this correct?
if(incidentPattern.test(userInput)){
userInput? All by itself? Perhaps the intend was vaVars.userInput?
if(incidentPattern.test(vaVars.userInput)){
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 09:12 PM
I think you are not passing the userInput variable properly. Try passing it like
if(incidentPattern.test(vaVars.userInput)){
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:14 AM
@PriyanshuVerma1 any follow-up help needed? Or was my answer sufficient?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field