- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 02:21 AM
Hi all,
Does anyone know if there is a way of setting a character limit on user input fields in Virtual Agent topics? We have done similar things on variables in catalog items by using the max_length attribute however I can't see a way of doing this in VA. Despite educating our users we are finding that they write war and peace when we ask them to explain their issue "in a few words" so we wanted to limit the amount of text they could input for certain questions. It would also be useful for Mobile number fields so that we could limit it to 11 digits.
Any help would be greatly appreciated.
Kind Regards
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 02:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 02:47 AM
And you can actual store this, so you don't need to use custom and code over and over again. I've written an article on this 3 years ago:
- 2021-01-11 - Article - Creating your own Virtual Agent Text Input Format Validators
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
01-19-2024 02:53 AM
Brilliant, I'll have a read as that'll be sure to save us a lot of time!
Much appreciated

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 06:47 AM
Thanks for the post; I hope to be able to use this in the future.
My current use case is a bit more specific. It seems that NLU cannot handle more than a 100 character utterance, and in my implementation, dumps the customer's text into a global search. I want the ability to intercede - advise the customer to say something else - and give NLU a chance to find the correct topic.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 11:23 AM
@Ryax1 - were you able to successfully use the suggested input validation to limit the customer's text?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:42 AM - edited 01-19-2024 01:43 AM
Hi Mary,
We weren't able to add the character limitation directly to the field, instead I added condition afterwards that checks the length of the text input; if the character length is 11 (which is the length of a UK mobile number) then the conversation continues, otherwise it loops back to asking for the contact number. You could also do some regex checks here to make this a bit more accurate. Here is the script for checking character length:
(function execute() {
var inputText = vaInputs.mobile_number.toString(); //Convert input to string
var stringLength = inputText.length; //Gets the length of string
if (stringLength == 11){
return true;
}
})()
I hope this is of some use to you! 😊