Incident Short Description Max Length Limit Not Honored?

brianlarue
Kilo Contributor

I would like to limit the number of characters entered in the Short Description field on the Incident form. Here's what I've tried:

Within the Form Designer, in the Short Description field properties (accessed by clicking the gear icon), there is an option for "Max Length." I have modified this to a more desirable number, e.g. 100, and saved the form. After reloading the form, it appears that this value has been reset to the 255 value. Why does this not accept the change? I imagine this can be accomplished by some client-side javascript although I am a new SNow admin. What are my options?

I hesitate modifying the data dictionary on the field in the database due to data loss.

1 ACCEPTED SOLUTION

Hey Brian,



Just switch the order of the functions, first setValue, then showFieldMessage .



Two advices, before the if statement do a hideFieldMessage to remove the text in case the user used less than 80 characters. The other one is to use info instead of error. You will be trimming the description, that means that the user can continue with his work. I don't like leaving red messages if the user doesn't need to modify anything.


View solution in original post

13 REPLIES 13

Manik
ServiceNow Employee
ServiceNow Employee

Hi Brian,



You can reduce the max length of 'Short Description' field by changing it in 'Data Dictionary' but this would lead to loss of data wherever 'Short Description' field from Task table is used and have a length more than 100.



Screen Shot 2017-07-19 at 10.58.31 PM.png



Thanks,


Manik



PS-   mark helpful, like and correct if it solves your problem


brianlarue
Kilo Contributor

I don't want to alter the data dictionary for all fields that reference that field on the task table. That would be a nuclear option. Is that my only choice?


Manik
ServiceNow Employee
ServiceNow Employee

Hi Brian,



Yes that would be the only option to restrict the limit in Short Description field would be by changing the length in Dictionary field else you can write a onSubmit client script to restrict the user from entering the short description of length more that 100.



Client Script:



Screen Shot 2017-07-19 at 11.09.02 PM.png



Thanks,


Manik



PS-   mark helpful, like and correct if it solves your problem


brianlarue
Kilo Contributor

I would much prefer when the maximum number of characters is exceeded, input is blocked, and a pop up notification is presented. This notification would notify them that they've exceeded the maximum allowable number of characters in that field. I've tried myself, except it doesn't appear to be working:



Capture.JPG



Sounds like that should be possible in an onChange event. Although, the API states that it only works on a "widget," is a "widget" a field on a form?