I came across a issue today that i never had thought about before. CRM allows you to sort a CRM Picklist in its base language only. This means that all other languages will see a more jumbled up list of Picklist values.
The client asked if it was possible to sort the other languages alphabetically as this was causing a lot of grief in the training,
Came up with this reorganises the picklist on the onLoad event.
sortPicklist =function(fld)
{
var field = document.getElementById(fld);
var ops= field.Options;
var nOptions = new Array();
for (var i = 0; i < ops.length; i++)
{
nOptions[i] = ops[i];
}
nOptions.sort(compare);
//Clear Picklist
field.innerHTML = "";
field.Options = nOptions;
}
compare = function(a,b) {
if (a.Text< b.Text)
return -1;
if (a.Text > b.Text)
return 1;
return 0; }
//Call the function using the picklist name
sortPicklist("new_mypicklist");