Our Service Desk requested a feature to display the number of open incidents for a user when logging a new call. While this information is accessible by clicking the small icon next to the Caller ID field, providing instant feedback directly on the form would enhance user experience and efficiency.

We implemented this feature in two parts:
- Adding a new function to our custom ‘incident utilities’ Script Include
- Creating a client script on the incident form that runs ‘onchange’ of the Caller ID field
Script Include
First, we extended our existing CustomIncidentUtils Script Include to add a method for retrieving the active incident count for a user:
var CustomIncidentUtils = Class.create();
CustomIncidentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getActiveCount: function() {
var userId = this.getParameter('sysparm_user_id');
var openCallCount = 0;
if (userId) {
var incidentGr = new GlideRecord('incident');
incidentGr.addActiveQuery();
incidentGr.addQuery('caller_id', userId);
incidentGr.query();
openCallCount = incidentGr.getRowCount();
}
return openCallCount;
},
type: 'CustomIncidentUtils'
});
This getActiveCount function:
- Retrieves the user ID passed as a parameter
- Queries the
incidenttable for active incidents associated with the user - Returns the count of open calls for the user
Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_scratchpad.uob_caller_info) {
var userOpenCallsAjax = new GlideAjax('CustomIncidentUtils');
userOpenCallsAjax.addParam('sysparm_name', 'getActiveCount');
userOpenCallsAjax.addParam('sysparm_user_id', g_form.getValue('caller_id'));
userOpenCallsAjax.getXMLAnswer(function(answer) {
var openCalls = parseInt(answer, 10);
if (!isNaN(openCalls) && openCalls > 0) {
var message = 'This user has ' + openCalls + ' active call' + (openCalls > 1 ? 's' : '') + '.';
g_form.showFieldMsg('caller_id', message, 'info');
}
});
}
}
This client script:
- Checks if the form is still loading or if the new value is empty, exiting if true
- Creates a new
GlideAjaxcall to ourCustomIncidentUtilsScript Include - Passes the current Caller ID as a parameter
- Retrieves the count of open calls for the user
- Displays an informative message below the Caller ID field if there are open calls
- Clears any existing messages if there are no open calls
Conclusion
Implementing this Open Call Count feature on the Incident form brings several benefits to our Service Desk operations:
- Improved Efficiency: Service Desk operators can now instantly see if a user has other open incidents without leaving the current form or performing additional searches.
- Better User Support: With immediate visibility into a user’s active incidents, operators can provide more informed and contextualized support.
- Enhanced Decision Making: This at-a-glance information helps in prioritizing and handling incidents more effectively.
- Scalable Solution: By leveraging a Script Include and client-side scripting, this feature is both performant and easily extendable to other parts of the system if needed.
This relatively simple enhancement demonstrates how small, targeted improvements can significantly impact the usability and effectiveness of our ServiceNow instance. As we continue to refine our processes, such user-centric features will play a crucial role in optimizing our service delivery and user satisfaction.



