- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:12 AM
Good evening
On a Catalog form, based on Country is Thailand, then it should allow the below 3 Address line Fields to only take 70 characters/digit length.
How can I do this? Please guide.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 04:42 AM
function onSubmit() {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:50 AM
Oh I see. Interesting Ankur. Can you please give me the code? I am confused, how can I check the variables length...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:55 AM
something like this in onSubmit
function onSubmit() {
// Get the country value
var country = g_form.getValue('countryVariable');
// Check if the country is Thailand
if (country == 'ThailandSysId') {
var val1 = parseInt(g_form.getValue('variable1'));
var val2 = parseInt(g_form.getValue('variable2'));
var val3 = parseInt(g_form.getValue('variable3'));
if (val1 + val2 + val3 > 70) {
g_form.addErrorMessage('Max address is 70 for Thailand');
return false;
}
}
}
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
02-26-2025 09:37 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 04:45 AM
Thanks a lot Ankur. I just modified and got the code as below:
Correct Answer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 01:48 AM
As per new community feature you can mark multiple responses as correct.
If my response helped please mark it correct as well so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader