- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 10:32 PM
Hi, Taking description field in Incident table as an example. I have set the Max length of description field to 4000 characters. But when i update this field through a script( i am not sure if the same happens when i update manually), i can even update 50000 characters. I dont want this to happen. Irrespective of the method of update, this description field should not take more than 4000 characters.
How do i add this restriction on the description field.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 12:21 AM
Hi,
Refer to these links. This gave an explanation of why certain fields it allows more than max length.
https://hi.service-now.com/kb_view.do?sysparm_article=KB0685779
If you want to override this behavior, then you shall go with client scripts and restrict input after specified no. of chars.
Mark the comment as a correct answer and helpful if it answers your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 10:38 PM
Hi,
The max length attribute works only with the string data type and not with others.
To restrict the max length to 4000 characters on your field, you can write an onchange client script like below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
{
return;
}
if(newValue.length>4000)
{
g_form.showErrorBox("your_field","You cannot enter more than 4000 characters",true);
}
}
Mark the comment as a correct answer and helpful if it answers your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 10:44 PM
Thanks, i can run this on onChange client script. but my question is when i have set the character limit in the dictionary entry of this string field, how is it not limiting to 4000 characters? how does it auto expand with character limit being 4000 in the dictionary entry?
Also, will this client script run on Journal fields?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 10:53 PM
Hi,
If the field is of string data type, then it will not allow you to go more than the mentioned characters. It will stop taking input.
Even the script will not work.
I just ran a code on my incident table short_description field (whose max length is 160) and it did not allow to enter more characters. When i run it through the script, it ran successfully, but the update never happened. The short description is still showing 160 chars data only.
Kindly check your field dictionary once.
The scripts work on any input field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 11:48 PM