Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

error onChange script error: RangeError: Maximum call stack size exceeded function ()

yoli1
Tera Contributor

Hi all, I have two onchange client scripts. Whenever field A changes, field B gets updated, and vice versa. The same applies to field B; when it changes, field A gets updated. However, I'm encountering an error: onChange script error: RangeError: Maximum call stack size exceeded function () { [native code] } It seems to be a loop between both onchange client scripts. Any ideas on how to solve this?

3 REPLIES 3

Dr Atul G- LNG
Tera Patron

Hi @yoli1 

 

The JavaScript RangeError: Maximum call stack size exceeded happens when a function keeps calling itself without any condition to stop, and eventually, the program runs out of space to keep track of these repeated calls. It's a sign that your program needs a way to stop the function from calling itself endlessly

 

Check the order of the client scripts.

 

https://www.servicenow.com/community/itsm-forum/getting-error-onchange-script-error-rangeerror-maxim...

https://www.servicenow.com/community/csm-forum/how-to-solve-onchange-script-error-rangeerror-maximum...

****************************************************************************************
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************

Danish Bhairag2
Tera Sage

Hi @yoli1 ,

 

Can u share ur script?

 

Thanks,

Danish