Override Max Length on single line text variable

Cirrus
Kilo Sage

Afternoon, is anyone able to confirm if this can be done please. When building a catalog item, is it possible to set a maximum length value on a single line text variable unique to that variable?

I cant change the current dictionary value because of the following warning: The field 'Question' on table 'Question' contains existing data records (3593) that exceed the new length

I did find one post that suggested this could be done by an on load client script, but I havent got it to work, tried question.question_text and current.variables.variable_name

 

function onLoad() {
setTimeout(function() {
jQuery('input[name="current.variables.variable_name"').attr("maxlength","10");
}, 1000);

1 ACCEPTED SOLUTION

Hi @Cirrus ,
If you will set the field "Variable attribute" to "max_length=1000", It will allow the user to enter the input into field till max length of 1000 charater.
If the field "Variable attribute" is not present on your form in default view, just bring it out by configure->form layout option.

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

View solution in original post

8 REPLIES 8

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Cirrus 

Greetings!

you can add variable attribute max_length=200

refer the below article:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0718701

Please hit the thumb and Mark as correct based on Impact!!

 

Kind Regards,

Ravi Chandra

Ravi, I may be being a little stupid here, but the article says:

  1. Navigate to the variable of single-line text or wide single line-text on the platform
  2. Open the Default Value tab
  3. Add the variable in Variables of single-line text or wide single line-text
    For example: max_length=150

What does line 3 actually mean? If I navigate to a single line text variable and put max_value=10 in the default value tab, it does just that, sets the default value of the field, not its length.

 

Also, is there a way to count characters in the portal. I know there is a system property in the UI.

 

Hello @Cirrus 

the article is little misguiding I'm afraid.

it's not the default value of the variable,

it is the default value of variable attribute. refer the below pic.

RaviChandra_K_0-1689259685416.png

Please hit the thumb and Mark as correct based on Impact!!

 

Kind Regards,

Ravi Chandra

Hello @Cirrus 

the property is  glide.ui.textarea.character_counter property

Please hit the thumb and Mark as correct based on Impact!!

 

Kind Regards,

Ravi Chandra