1. AbstractAjaxProcessor — the server-side contract
“You're asked to build a server-side GlideAjax API that returns the count of open incidents for a given assignment group. What class do you extend, and what methods matter?”
How to answer
- Extend AbstractAjaxProcessor in a Script Include — this is the only supported server-side base class for GlideAjax.
- Use this.getParameter('parm_name') to read values sent from the client.
- Return data with this.getParameterAnswer('result_key') so the client can read it in getXMLAnswer().
- Keep the process() or processAnswer() method name matching what the client calls in getXMLWait() / getXMLAnswer().
Reference script
var GlideAjaxIncidentCount = Class.create();
GlideAjaxIncidentCount.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getOpenCount: function() {
var groupId = this.getParameter('sys_id');
var gr = new GlideRecord('incident');
gr.addQuery('assignment_group', groupId);
gr.addQuery('state', '!=', 7); // not Closed
gr.query();
this.getParameterAnswer('count', gr.getRowCount());
}
});Pitfall
Forgetting that getParameter() returns strings — comparing directly to a number with === fails. Cast with parseInt() or use == for loose equality when reading numeric parameters.