Modifying Feature Templates - changes with 1.4?

1044
1
01-19-2017 05:40 AM
Highlighted
New Contributor II

I am creating an add-in, and one piece of required functionality is to change the default value of a text field in a layer's editing template(s).  I had this working in 1.3, but when I upgraded to 1.4, it no longer works.  The code runs without error, but the default value is not changed in any of the templates when I look at them in Pro.  However, if I re-run the functionality and step through the code, the value IS changed in the CIM layer definition templates.  To confirm that there is not an issue with another part of my add-in, I created a test module with just this functionality and am seeing similar problems. 

Below is the method that I am calling from a button click on a simple dock pane, which also has a text box for the new value.  My project has a layer named Parcels with a text field named TestFld.  How do I change default values for a template? If this change is due to 1.4, is there a resource that describes these changes in case I find other problems with the upgrade?

Thank you,

Kelley


private async Task UpdateTemplateDefaultValue()
{
    //Get parcels layer
    var featLayer = MapView.Active.Map.FindLayers("Parcels").First();
           
    await QueuedTask.Run(() =>
    {
        //Get CIM layer definition
        var layerDef = featLayer.GetDefinition() as CIMFeatureLayer;

        //Get all templates on this layer
        var layerTemplates = layerDef.FeatureTemplates.ToList();
        CIMFeatureTemplate featTempl;
        // Update the default value for TestFld
        foreach (var templ in layerTemplates)
        {
            featTempl = templ as CIMFeatureTemplate;
            featTempl.DefaultValues["TestFld"] = _fieldValue;
        }
        //Set the layer definition templates from the list
        layerDef.FeatureTemplates = layerTemplates.ToArray();
        //Finally set the layer definition
        featLayer.SetDefinition(layerDef);
    });
}
0 Kudos
1 Reply
Highlighted
Esri Regular Contributor

Kelley,

Your code is fine, this is a bug with 1.4, the default values cant be set via the SDK. There is no workaround at this time.

0 Kudos