Select to view content in your preferred language

Access coded domain values

165
2
4 weeks ago
Labels (1)
RavinHasseea
Emerging Contributor

Hi, I am loading the data from a mobile geodatabase, which includes the Utility Network.

I can see the geodatabase contain the field domains. However, I'd like to display the field domain value description, instead of the code in a popup.

Any suggestions ?

 

Tags (1)
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor

Something like this should work:

 

 

private static string GetDisplayValue(Field field, Feature feature)
{
    if (field is null || feature is null || !feature.Attributes.ContainsKey(field.Name))
        return string.Empty;
    var value = feature.Attributes[field.Name];
    if (field.Domain is CodedValueDomain cvd)
    {
        value = cvd.CodedValues.FirstOrDefault(c => c.Code == value)?.Name ?? value;
    }
    return value?.ToString() ?? string.Empty;
}

 

0 Kudos
RavinHasseea
Emerging Contributor

Thanks @dotMorten_esri .  This should work, but unfortunately it doesn't.

 

cvd.CodedValues.FirstOrDefault(c => c.Code == value)?.Name ?? value;

Still gives me the code, instead of the name. I can see the name is populated when debugging.

Also I need to include Asset Group and Asset Types description.

0 Kudos