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
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">async</SPAN> Task <SPAN class="token function">UpdateTemplateDefaultValue</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//Get parcels layer</SPAN>
<SPAN class="keyword token">var</SPAN> featLayer <SPAN class="operator token">=</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindLayers</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Parcels"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">First</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//Get CIM layer definition</SPAN>
<SPAN class="keyword token">var</SPAN> layerDef <SPAN class="operator token">=</SPAN> featLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDefinition</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> CIMFeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Get all templates on this layer</SPAN>
<SPAN class="keyword token">var</SPAN> layerTemplates <SPAN class="operator token">=</SPAN> layerDef<SPAN class="punctuation token">.</SPAN>FeatureTemplates<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
CIMFeatureTemplate featTempl<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Update the default value for TestFld</SPAN>
<SPAN class="keyword token">foreach</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> templ <SPAN class="keyword token">in</SPAN> layerTemplates<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
featTempl <SPAN class="operator token">=</SPAN> templ <SPAN class="keyword token">as</SPAN> CIMFeatureTemplate<SPAN class="punctuation token">;</SPAN>
featTempl<SPAN class="punctuation token">.</SPAN>DefaultValues<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"TestFld"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> _fieldValue<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">//Set the layer definition templates from the list</SPAN>
layerDef<SPAN class="punctuation token">.</SPAN>FeatureTemplates <SPAN class="operator token">=</SPAN> layerTemplates<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToArray</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Finally set the layer definition</SPAN>
featLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetDefinition</SPAN><SPAN class="punctuation token">(</SPAN>layerDef<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>