The CreatorCon Call for Content is officially open! Get started here.

How to give max length for a variable on catalog item?

swathigangadhar
Tera Expert

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.

1 ACCEPTED SOLUTION

karthikdurga
Mega Expert

Create a variable of type macro, and in the macro define an input field of size 255. Sample code is provided below.



sa.JPG


View solution in original post

5 REPLIES 5

antin_s
ServiceNow Employee
ServiceNow Employee

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


Hi Antin,



I tried it for wide single line text field, but it is restricting to 160 characters only.


karthikdurga
Mega Expert

Create a variable of type macro, and in the macro define an input field of size 255. Sample code is provided below.



sa.JPG


vinothkumar
Tera Guru

Hi Swathi,



You can also accomplish the same via   by simple onChange client script



  1. var field = g_form.getValue('short_description').length;  
  2. if(field>254)  
  3.   {  
  4.   alert('YOUR TEXT');  
  5.   return false;  
  6. }