Catalog Variable "Select Box" Using Choice Table - How to Alphabetize the List (not choice list)

jlaps
Kilo Sage

I have a variable used on my incident record producer for users to pick the application from a list they are having trouble with. This list is derived from the BUSINESS APPLICATION table where a field there indicates to be included or not. I have a request to have the list be alphabetized... but I see no way to do this. What am I missing, or what options do I have?

jlaps_0-1749052691428.png

 

5 REPLIES 5

palanikumar
Mega Sage

Hi,

In Variable attributes type the below value:

ref_ac_order_by=<name of the sorting field>

 

Refer below URL for more details:

https://www.servicenow.com/docs/bundle/yokohama-servicenow-platform/page/product/service-catalog-man...

 

Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

@jlaps 

try to add this in reference qualifier

ORDERBYsequence

I was able to order it based on sequence for Category field

AnkurBawiskar_2-1749053763847.png

 

AnkurBawiskar_0-1749053714426.png

AnkurBawiskar_1-1749053729925.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

This does not seem to work, I think because the list is not generated from a sys_choice table, but from the Business Application table directly. Or I am not doing it right,

jlaps_0-1749057586149.png

jlaps_1-1749057605404.png

 

So on this record producer, there is a catalog client script that seems to be doing things. Not sure if I can add a sort into this onChange catalog client script?

function onChange(control, oldValue, newValue, isLoading) {
    if (newValue == oldValue) {
        return;
    }

    // clear options and add -- None -- option back
    g_form.clearOptions('specify_issue_item');
	g_form.clearOptions('u_user_selected_app_ba');
    g_form.addOption('specify_issue_item', '', '-- None --');
	
    var ga = new GlideAjax('getIncidentTypes');
	ga.addParam('sysparm_name', 'getIncTypes');
    ga.addParam('sysparm_incType', newValue);
    ga.getXMLAnswer(itemTypes);

    function itemTypes(answer) {
        var typeData = JSON.parse(answer);
        for (i = 0; i < typeData.ids.length; i++) {
			g_form.addOption('u_user_selected_app_ba', typeData.ids[i], typeData.apps[i]);
        }
    }

}