To limit Short description length to 80 characters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 09:10 AM
Hi,
I have got a requirement wherein the short description field in Incident form should be limited to 80 characters.
User who is typing should be able to type only 80 characters and when he/she types the 81st character, an error message should be displayed and not allow to type more.
Please help me with this. Thanks in advance!!!
Regards,
Gopi
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 09:24 AM
Hello Gopi,
The short description field is a field that is inherited from the task table. I would highly recommend not decreasing the max length as I can see that OOB this is set to 160. By decreasing max length this will affect the short description across the task hierarchy (all short description fields on all extended tables of task) and can lead to potential dataloss. We do not ever recommend decreasing max length (special case exception if you have created a new custom column and then want to change it so long as there is no data). If you decide to do so it will be at your own risk.
What you are essentially looking for though would probably be a before update business rule where we check the current character count in that field and if it exceeds 80 then throw a dialog that indicates only 80 characters can be used in the field and then abort the update action.
Chris
Sr. Technical Support Engineer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 09:30 AM
I've seen on previous customer instances (I don't have the code anymore) where an onChange Client Script calculated the length of the field, and if it was greater than 80 chars, it would trim it back to the first 80.
Note: This won't work when editing the short_description in List View.
Jarod
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 10:22 AM
Hi Gopi!
I would go with a little of what Chris suggested and a little of what Jarod suggested.
Business Rule
Condition: current.getValue("short_description").length > 80
Script:
current.abortAction(true);
gs.addErrorMessage("The short description field can be no more than 80 characters")
Client Script
Type: onChange
Script:
var sDesc = g_form.getValue("short_description");
if (sDesc.length > 80) {
g_form.showFieldMsg("short_description", "The short description field can be no more than 80 characters", "error");
g_form.setValue("short_description", sDesc.substring(0,79));
}
I haven't tested those scripts, but they should get you 90% there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2017 02:19 PM
Gopikrishnan,
We are glad you took advantage of the ServiceNow Community to learn more and to get your questions answered. The Customer Experience Team is working hard to ensure that the Community experience is most optimal for our customers.
If you feel that your question was answered, we would greatly appreciate if you could mark the appropriate thread as "Correct Answer". This allows other customers to learn from your thread and improves the ServiceNow Community experience.
If you are viewing this from the Community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thanks,
Shivani Patel