1 Select Box choice to be display at the bottom

narayansaha
Tera Contributor

Hello All,

Good day! I would like to get some help on 1 stuff, where a select box choices should be displayed in alphabetical order.
However, there are some cases, where choices like "Any other"/ "Other" should be displayed at the bottom.

The select box and the choices are specific to the Application Name selected. And we have configured a catalog client script, script include and custom table, from where we are populating the choice list for specific Application Name.

I want to know, how we can put the choices like "Any other", "Other" at the bottom, while the remaining choice lists to be in alphabetical order.

Dropdown.jpg

Catalog Client Script: OnChange of "Application Name" variable

function onChange(control, oldValue, newValue, isLoading) {

  if(newValue == oldValue){

  return;

  }

  if(!isLoading && newValue!=''){

  var appName=g_form.getReference('<Application Name variable>').name;

  g_form.getControl('App_Issue_Type').options.length = 1;

  var ajax=new GlideAjax('XL_SCAT_ChoiceList1_SoftwareIssues');

  ajax.addParam('sysparm_name','choiceLis1Values');

  ajax.addParam('sysparm_choice',appName); //Pass userID as parameter

  ajax.getXMLWait();

  var ans = ajax.getAnswer();

  var list1=ans.split('^');

  for(var i=1;i<list1.length;i++){

  g_form.addOption('<Type of Issue>', list1[i],list1[i]);

  }

  }

}

Script Include: Client Callable checked

var XL_SCAT_ChoiceList1_SoftwareIssues = Class.create();

XL_SCAT_ChoiceList1_SoftwareIssues.prototype = Object.extendsObject(AbstractAjaxProcessor, {

  choiceLis1Values: function() {

  var answer='';

  var choice=this.getParameter('sysparm_choice');

  //var element=this.getParameter('sysparm_element');

  var gp = new GlideRecord('u_xl_scat_choice_list_table');

  gp.addQuery('u_reference_field', choice);

  gp.orderBy("u_field_1");

  gp.query();

  while(gp.next()){

  if(answer.lenght==0){

  answer=gp.u_field_1;

  }else{

  answer=answer+"^"+gp.u_field_1;

  }

  }

  return answer;

  }

});

Custom Table: XL SCAT Choice List Tables

XL SCAT Choice List Tables.jpg

Any urgent help should be highly appreciated.

Regards,

Narayan Saha

7 REPLIES 7

Try to change the order of choice and define 5,000 for Any Other choice and check once


No change.


amaradiswamy
Kilo Sage

Just change the order and revert all changes to the script. For me it is working and made below changes to script include


var XL_SCAT_ChoiceList1_SoftwareIssues = Class.create();


XL_SCAT_ChoiceList1_SoftwareIssues.prototype = Object.extendsObject(AbstractAjaxProcessor, {


  choiceLis1Values: function() {


  var answer='';


  var choice=this.getParameter('sysparm_choice');


  //var element=this.getParameter('sysparm_element');


  var gp = new GlideRecord('u_xl_scat_choice_list_table');


  gp.addQuery('u_reference_field', choice);


//   gp.orderBy("u_field_1"); //comment this field which is giving choices in alphabetical order


  gp.query();


  while(gp.next()){


  if(answer.lenght==0){


  answer=gp.u_field_1;


  }else{


  answer=answer+"^"+gp.u_field_1;


  }


  }


  return answer;


  }


});