onChange script error: RangeError: Maximum call stack size exceeded function () { [native code] }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 07:40 PM - edited 03-27-2024 07:56 PM
Hi All,
I have 2 checkboxes on a form and there are 2 onchange client scripts on each of them. Whenever I tried to make update it, I am getting below error
onChange script error: RangeError: Maximum call stack size exceeded function () { [native code] }
below is the script on checkbox1:
below is the script on checkbox2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 10:47 PM
I would suggest you start from your side so that you will learn.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 01:04 AM
@pramodkumar Did you try the solution suggested by me?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 09:27 PM - edited 03-27-2024 09:29 PM
@pramodkumar Inside the onChange script of Checkbox 1, you are checking if the checkbox 2 is already checked and then clearing the value of checkbox1 which is causing a recursive function call for the onChange client script for checkbox 1. You are doing the same thing for checkbox 2 as well and both of these scripts are causing infinite loop.
I recommend addressing this requirement via a UI Policy and its script field as follows.
1. UI Policy on Checkbox 1
2. UI Policy on Checkbox 2.
Do not forget to deactivate your onChange client scripts on checkbox 1 and checkbox2 before applying this solution.
Hope this helps.