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

Is there any way to make a string field of at least 40 character or we have configure through script

1_DipikaD
Kilo Sage

Hi All,

 

I want to make character length of a string field of at least 40 character . Is there any way configure it without scripting or we have to approach through script ?

 

Thank You

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@1_DipikaD 

on string field in dictionary you can use max_length to allow max characters

but nothing OOTB is present for minimum length

you will require onChange client script for this.

AnkurBawiskar_0-1759471075625.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

mayankkumar
Kilo Patron
Kilo Patron

Hi @1_DipikaD,
You can set the maximum character length in the Dictionary for that field. However, if you also want to ensure the field contains at least 40 characters, you’ll need to add an onChange client script on field to enforce that.
----------------------------------------------------------------------------------------------------------------------------------------------
Please mark my response helpful and accept as solution
Thanks & Regards
Mayank

View solution in original post

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

@1_DipikaD 

on string field in dictionary you can use max_length to allow max characters

but nothing OOTB is present for minimum length

you will require onChange client script for this.

AnkurBawiskar_0-1759471075625.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @1_DipikaD 

 

There is no direct regular expressions, non-scripting way to enforce a minimum length of 40 characters, If you want to avoid writing a script, the only relevant configuration option available on the Dictionary record for a string field is the Max length property, which enforces a maximum limit, not a minimum.

 

Regular expression are available for only variables fields.

 

If this helped to answer your query, please mark it helpful & accept the solution.
Thanks!
Krishnamohan

@Ankur Bawiskar 

While trying it returns unknown in place of oldValue also tried to fix it through setValue method but it's not working as expected. Could you please suggest how to fix it ?

 

Thank You

@1_DipikaD 

please share your final script and what's the error you are getting?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader