- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 01:00 AM
How to give max length for a variable on catalog item?
For a text field i need to restrict length to 255 character on item field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 01:51 AM
Create a variable of type macro, and in the macro define an input field of size 255. Sample code is provided below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 01:08 AM
Please add 'max_length=255' to the variable attributes. Please refer the below URL.
Variable Types - ServiceNow Wiki
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 01:17 AM
Hi Antin,
I tried it for wide single line text field, but it is restricting to 160 characters only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 01:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 02:48 AM
Hi Swathi,
You can also accomplish the same via by simple onChange client script
- var field = g_form.getValue('short_description').length;
- if(field>254)
- {
- alert('YOUR TEXT');
- return false;
- }