Select to view content in your preferred language

Duplication of table-level domains and default values at the subtype level for all subtypes

269
2
Jump to solution
02-28-2024 03:01 PM
ljlopez
New Contributor III

Hi all,

I'm using the ArcGIS Pro 3.1 SDK for .NET to copy feature classes to a FileGeodatabase, including domains, subtypes and default values, and I have come across an unexpected behaviour. When domains and default values are defined only at the table level in the original table, they get defined both at the table level and for every subtype in the resulting table. See screen capture below.

Original and resulting tables.Original and resulting tables.

Is that the expected behaviour? Does the ArcGIS Pro SDK automatically assign table-level domains and default values to all the subtypes? I'm asking because I have checked the corresponding FieldDescription instances and they contain NO domains or default values for any of the subtypes, but when the feature class is created and opened in ArcGIS Pro, there they are defined for every subtype.

I'm including below an extension method for the Field class that I use to generate the field description, but the issue is the same both with the code below or simply using "new FieldDescription(field)".

internal static FieldDescription GetFieldDescription(this Field field, IReadOnlyList<Subtype> subtypes)
{
    var fieldDescription = new FieldDescription(field);
    object defaultValue;
    Domain domain;

    foreach (var s in subtypes)
    {
        defaultValue = field.GetDefaultValue(s); // Default value at the subtype-specific level.
        if (defaultValue != null) fieldDescription.SetDefaultValue(defaultValue, s.GetCode());

        domain = field.GetDomain(s); // Domain at the subtype-specific level.
        if (domain is CodedValueDomain) fieldDescription.SetDomainDescription(new CodedValueDomainDescription(domain as CodedValueDomain), s.GetCode());
        else if (domain is RangeDomain) fieldDescription.SetDomainDescription(new RangeDomainDescription(domain as RangeDomain), s.GetCode());
    }

    defaultValue = field.GetDefaultValue(); // Default value at the table level.
    if (defaultValue != null) fieldDescription.SetDefaultValue(defaultValue);

    domain = field.GetDomain(); // Domain at the table level.
    if (domain is CodedValueDomain) fieldDescription.SetDomainDescription(new CodedValueDomainDescription(domain as CodedValueDomain));
    else if (domain is RangeDomain) fieldDescription.SetDomainDescription(new RangeDomainDescription(domain as RangeDomain));

    return fieldDescription;
}

Any ideas of what could be happening?

Thanks

0 Kudos
1 Solution

Accepted Solutions
Aashis
by Esri Contributor
Esri Contributor

Thank you for bringing this bug to our attention. We will fix it in Pro SDK 3.3.

View solution in original post

2 Replies
Aashis
by Esri Contributor
Esri Contributor

Thank you for bringing this bug to our attention. We will fix it in Pro SDK 3.3.

ljlopez
New Contributor III

Thanks @Aashis! I can confirm that the issue is fixed in the version 3.3 of the ArcGIS Pro SDK.