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

Great! That finally resolved the issue. Thanks for your help!



However, I'm a bit puzzled why changing the order of the statements (placing the showFieldMsg after setValue) fixed it. Why would this make a difference?


No idea. I saw that the script was correct, so I started trying different stuff! I suppose that the value overrides whatever appears in the message fields, but I'm just guessing here.


Thanks again for all of your help. This just in... is there a way to disable saving/updating the form if the "short description" exceeds the maximum number of characters? Say by scripting or disabling of the buttons on the form? Can this be done via scripting or a UI action?


Of course, the same validation you do it in an onChange client script, you do it on an onSubmit. Then, add a "return false;" and the ticket won't be created. In that case, also add an error message at the top saying that the short description should be shorter.