- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 10:13 PM
Getting below error in onchage client script.
onChange script error: RangeError: Maximum call stack size exceeded function () { [native code] }
code which i am using.
var regex = /^(1[0-3]|[1-9])$/;
if (!regex.match(newValue)) {
g_form.showFieldMsg('xxx', 'Please enter a number between 1 and 13.', 'error');
g_form.setValue('xxx', 0);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 11:37 PM - edited 12-22-2024 11:37 PM
Hey @MK-p ,
Clear Value clears value as well as messages related to the field, can you try adding error message post clearing value as below.
var regex = /^(1[0-3]|[1-9])$/;
if (!regex.match(newValue)) {
g_form.clearValue('xxx');
g_form.showFieldMsg('xxx', 'Please enter a number between 1 and 13.', 'error');
}
---------------------------------------------------------------------------------------------------
Please mark my answer as helpful/correct if it resolves your query.
Thanks,
Nilesh Wahule
---------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 11:52 PM
Hi @MK-p ,
Put clear message before field message.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 10:19 PM
Hi @MK-p ,
This is happening because it is your code is executing multiple time on onChange.
Either you can clear the filed or terminate the loop post error.
you can do like below.
var regex = /^(1[0-3]|[1-9])$/;
if (!regex.match(newValue)) {
g_form.showFieldMsg('xxx', 'Please enter a number between 1 and 13.', 'error');
g_form.clearValue('xxx');
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 10:57 PM
Hi @Runjay Patel ,
I need to display the message, after adding your suggestion error is not coming but message also not appearing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 11:37 PM - edited 12-22-2024 11:37 PM
Hey @MK-p ,
Clear Value clears value as well as messages related to the field, can you try adding error message post clearing value as below.
var regex = /^(1[0-3]|[1-9])$/;
if (!regex.match(newValue)) {
g_form.clearValue('xxx');
g_form.showFieldMsg('xxx', 'Please enter a number between 1 and 13.', 'error');
}
---------------------------------------------------------------------------------------------------
Please mark my answer as helpful/correct if it resolves your query.
Thanks,
Nilesh Wahule
---------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 11:52 PM
Hi @MK-p ,
Put clear message before field message.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------