Looking forward to see what you come up with. This service has several layers with coded value domains: http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/Energy/Geology/MapServer
We query each layer for the layer description. We then pass the resulting featureset through a function to replace names with aliases, format numbers, and replace domains with their valuesFunction to do formatting/aliases/domainsorg.mymanatee.common.util.getAliasDomainFormat=function(layerdesc, fieldName, field_val){
dojo.forEach(layerdesc.fields, dojo.hitch(this, function(ldf){
if(ldf.name==fieldName){
//replace with aliases
fieldName = ldf.alias;
// alert(ldf.name+" : "+ldf.type);
if(ldf.type=="esriFieldTypeDate"){
// alert(ldf.type);
field_val= dojo.date.locale.format(new Date(field_val), {datePattern: "MM/dd/yyyy"});
// alert(field_val);
}
if(ldf.type=="esriFieldTypeDouble"){
// alert(ldf.type);
field_val= dojo.number.format(field_val,{places: 2 });
// alert(field_val);
}
if(ldf.domain){
dojo.forEach(ldf.domain.codedValues, dojo.hitch(this, function(domain){
if(field_val==domain.code){
field_val=domain.name;
}
}));
}
}
}));
return [fieldName,field_val];
}
function to get the layer description (by querying url with the ?f=json parameter) - ignore the replaces they are a cross-domain hackorg.mymanatee.common.util.getLayerDesc=function(url){
var desc;
var layerurl= ""+url.replace("http://home.intranet","")+"/?f=json";
layerurl= ""+layerurl.replace("http://www.mymanatee.org","");
var params = {
url: layerurl,
handleAs: "json",
sync: true
};
var deferred =dojo.xhrGet(params);
desc= deferred.results[0];
return desc;
}