is there a way to sort the options that we add to a list with g_form.addOption()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2014 03:11 AM
is there a way to sort the options that we add to a list with g_form.addOption()?
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2014 02:20 AM
Hi Chandana,
Thanks for that sorry for not being clear, I mean was I was not able to get my head around where to use the array, Below is the script if you don't mind helping me to sort that out?
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcat drop down to start
// Used the g_form.clearOptions() function instead of g_form.removeOption() function
g_form.clearOptions('service_name');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'service_name');
gp.query();
while(gp.next()){
g_form.addOption('service_name', gp.value, gp.label);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2014 02:24 AM
Hi Vikrant,
Can you tell me on what basis you would want to sort ? is it based on value or label and can you give me couple of sample values and labels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2014 02:27 AM
It would be lable,
Below are some sample lables:
Dynamo |
FAST |
GET |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2014 02:46 AM
Hi Vikrant,
I had sent you a message, couldnt type the whole code again.
Let me know if you have received it, otherwise I will try to put it here again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2014 02:50 AM
Hi Chandana, Got it. Thanks for the help.