how to limit the character on the multi line text catalog variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2025 02:35 AM
Hi,
how to limit the character on the multi line text catalog variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2025 02:39 AM
you will have to write onChange client script on that variable and validate
you cannot give anything in variable attributes in catalog
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2025 02:44 AM
Hi Ankur,
Tried this but it doesnot work;
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var currentLength = newValue.length;
if (currentLength > 10) {
newValue = newValue.substring(0, 10);
g_form.setValue("name", newValue);
g_form.showFieldMsg("name", "Maximum entry is 10 characters.!",'error');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2025 02:52 AM
what debugging did you do?
Update as this to hide the field message whenever onchange runs
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('name');
var currentLength = newValue.length;
if (currentLength > 10) {
newValue = newValue.substring(0, 10);
g_form.setValue("name", newValue);
g_form.showFieldMsg("name", "Maximum entry is 10 characters.!", 'error');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2025 03:15 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader