Newly updated Choice Labels are unable to show up in Service portal

New Developer_S
Giga Sage

Hi, 

I have made a Choices Label Changes ( renamed existing choices ) for a List collector Variable for a Service Catalog item. When I test it in Service portal, newly made changes for Choice Labels are unable to retrieve the Label changes ( Instead , of Labels, I am getting values of choices ) . For all other Old choice entries -Labels are retrieving correctly.

I am using On change Client script and GlideAjax call .Is there any limitation for Choice Labels ? I have searched all the community for the related queries , but I found no help. If anyone face this kind of issue, please help.

P.s: i have a reference qualifier on the Variable , which is also working fine for other choice labels.I can share the code if needed. 

Kindly help.

 

Regards,

Tia.

4 REPLIES 4

Rajesh Chopade1
Mega Sage

Hi @New Developer_S 

Sometimes, changes may not reflect immediately due to caching. You can try clearing the browser cache or using a different browser to see if the changes appear. Additionally, ensure that the ServiceNow instance cache is cleared:

  • In Navigator type cache.do and press enter

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh

@Rajesh Chopade1 
thank you for time for answering, unfortunately it is NOT about the cache.

hi @New Developer_S 

 

Make sure that the choice labels have been correctly updated in the sys_choice table. Sometimes, the updates may not save properly.

 

Since you mentioned that you're using a reference qualifier, ensure that it’s not affecting the retrieval of choice labels. The qualifier might be filtering the available choices incorrectly or not reflecting the updated labels.

 

you’re using an onChange client script along with GlideAjax, double-check that your script is not inadvertently overriding the choice labels.

 

If you still face issues, feel free to share specific code snippets or configurations, and I’ll be happy to assist further!

@Rajesh Chopade1 
This is my Catalog Client Script : UI Type Set to ALL 

 

function onChange(control, oldValue, newValue, isLoading) {
    var preLoadId = getParameterValue('system_id');

    // If it is loading and a system_id (sys_id of it system inventory entry), load the values
    if (isLoading && preLoadId) {
        g_form.setValue('it_system_inventory_entry', preLoadId);
        loadEntrysById(preLoadId);
    }

    // If the new value is empty, clear values
    if (newValue == '') {
        var fieldNames = JSON.stringify(g_form.getFieldNames());
        for (var i in fieldNames) {
       
            g_form.clearValue(fieldNames[i]);
        }
    }

   
    // If the new value differentiates from the old value and the new value is not empty, load the values
    else if (newValue != oldValue && newValue !='') {
   
        loadEntrysById(newValue);
    }
}

function loadEntrysById (sysId) {
    var ga = new GlideAjax('clientHelper');
    ga.addParam('sysparm_name', 'loadSystemInvetoryEntryGr');
    ga.addParam('system_inventory_sys_id', sysId);
    ga.addParam('fields', JSON.stringify(g_form.getFieldNames()));
    ga.getXML(ajaxResponse);

    function ajaxResponse (response) {
   
        var answer = JSON.parse(response.responseXML.documentElement.getAttribute('answer'));
       
        for (var i in answer) {
       
           
            if (answer[i].key != 'it_system_inventory_entry') {
            g_form.setValue(answer[i].key, answer[i].value);
           
               
               
            }
        }
    }
}

/**
 * Retrieves the url parameter by name
 *
 * @param {String} name - The name of the url parameter
 * @returns {String} The value of the url parameter
 */
function getParameterValue(name) {
    var ret = '';
    var url = top.location.href;
    ret = new URLSearchParams(url).get(name);

    return ret;
}
 
Script Include Function : 
 
/**
     * Load GlideRecord Object of System Inventory by sys_id of entry
     *
     * @returns {Array} - Array of key (field name) and values (field values)
     */
   loadSystemInvetoryEntryGr: function() {
        var debugMessage = 'The function loadSystemInvetoryEntryGr has been called';
        var ret = [];
        debugMessage += '\n' + this.getParameter('system_inventory_sys_id') + '\n' + this.getParameter('fields');
        try {
            var systemInvetoryEntry = this.getParameter('system_inventory_sys_id');
            var fields = JSON.parse(this.getParameter('fields'));
            var gr = new GlideRecord('cmdb_ci_business_app');
            if (gr.get(systemInvetoryEntry)) {
                for (var i in fields) {
                    var temp = {};
                    temp.key = fields[i];
                    temp.value = gr.getValue(fields[i]);
                    ret.push(temp);
                }
            }
        } catch (ex) {
            this._log.logErr(debugMessage + '\nError: ' + ex);
        }
        debugMessage += '\nReturn: ' + JSON.stringify(ret);
        gs.info(debugMessage);
        return JSON.stringify(ret);
    },

   Please drop some ideas where i am doing a mistake here..