Show Hints for choice lists

A stakeholder asked me to show hints in a more obvious way on a form. This was my suggestion. Using the hint field on the sys_choice table. Have a client script onChange check for the value, if one is set, clear the message for this field, and show the found message.

//script include global.choiceUtil
//client callable true
var choiceUtil = Class.create();
choiceUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getHint: function() {
        try {
            var returnObj = {};
            var hint = new GlideRecord('sys_choice');
            hint.addQuery('name', this.getParameter('sysparm_table'));
            hint.addQuery('element', this.getParameter('sysparm_field'));
            hint.addQuery('value', this.getParameter('sysparm_val'));
            hint.addQuery('inactive', 'false');
            if ( {
                returnObj.hint = hint.getValue('hint');
            } else {
                returnObj.error = 'no choice found for ';
                returnObj.error += hint.getEncodedQuery();
			//returnObj.query = hint.getEncodedQuery();
            return JSON.stringify(returnObj);
        } catch (error) {
            return JSON.stringify(error, '', '  ');
    type: 'choiceUtil'
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
    var field = 'state';

	var ga = new GlideAjax('global.choiceUtil');
    ga.addParam('sysparm_name', 'getHint');
    ga.addParam('sysparm_table', g_form.getTableName());
    ga.addParam('sysparm_field', field);
    ga.addParam('sysparm_val', newValue);

    function HintParse(response) {
        var answer = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
        g_form.hideFieldMsg(field, true);
        if (answer.hint) {
            g_form.showFieldMsg(field, answer.hint, 'info', true);


Here’s the OOB

Here’s the alternate

Edit this page

Jace Benson
ServiceNow Developer

ServiceNow is my day job, JAMStack is my passion.