- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 10:15 AM
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.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 06:29 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 03:29 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 03:37 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 10:29 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 11:26 AM
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.