how to limit the character on the multi line text catalog variable?
Options
- 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?
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2025 07:45 PM
Hope you are doing good.
Did my reply answer your question?
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2025 02:45 AM
Hello @Mada11 ,
You can create an onChange client script as below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var charLimit = 250;
var field_value= g_form.getValue('field_value'); // use backend value of your variable
if (field_value.length > charLimit){
g_form.setValue('field_value', field_value.substring(0, charLimit));
g_form.addFieldMessage('field_value', 'Maximum character limit exceeded. Please limit your input to ' + charLimit + ' characters.');
return false;
}else{
g_form.clearMessages();
return true;
}
}
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ashish