How to fix it
- Navigate to
System Definition > Script Includesand open your Script Include record. - Check the
Client callablecheckbox. If unchecked, check it and click Update. This makes the Script Include accessible from client-side code. - Verify the Script Include
Namefield exactly matches what you use innew GlideAjax('ScriptIncludeName'). Case matters. - In the Script Include code, ensure your method calls
this.setAnswer(returnValue)to send data back to the callback. - Check that the method name in
addParam('sysparm_name', 'methodName')exactly matches a function in your Script Include. - Navigate to
System Logs > System Log > Alland filter by your Script Include name to check for JavaScript errors. - If using the traditional pattern, ensure your Script Include extends
AbstractAjaxProcessorand methods are defined asClassName.prototype.methodName = function(). - Test your fix by refreshing the form and triggering the GlideAjax call again.
Add console.log statements in both your client script callback and Script Include method to verify data flow. Check browser console and system logs respectively.
- If returning objects or arrays, use
this.setAnswer(JSON.stringify(myObject))in the Script Include andJSON.parse(answer)in the callback. - Clear your browser cache if the Script Include was recently modified, as ServiceNow may cache the old version.