<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Set attributes in featurelayer edittemplate in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1031807#M6288</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've created feature layer from featureservice. I've almost 73 predefined edit templates and want to add couple of attributes to each template after layer is getting added on map.&lt;/P&gt;&lt;P&gt;I got all templates using below code but not sure how to get predefined attributes and set values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  IEnumerable&amp;lt;FeatureLayer&amp;gt; featLayers = theMap.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;();

foreach (FeatureLayer item in featLayers)
{
   foreach (var template in MappingExtensions.GetTemplates(item))
    {
      //Define attribute for each template.
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;-Prashant&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 07:08:50 GMT</pubDate>
    <dc:creator>PrashantKirpan</dc:creator>
    <dc:date>2021-03-02T07:08:50Z</dc:date>
    <item>
      <title>Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1031807#M6288</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've created feature layer from featureservice. I've almost 73 predefined edit templates and want to add couple of attributes to each template after layer is getting added on map.&lt;/P&gt;&lt;P&gt;I got all templates using below code but not sure how to get predefined attributes and set values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  IEnumerable&amp;lt;FeatureLayer&amp;gt; featLayers = theMap.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;();

foreach (FeatureLayer item in featLayers)
{
   foreach (var template in MappingExtensions.GetTemplates(item))
    {
      //Define attribute for each template.
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;-Prashant&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 07:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1031807#M6288</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-03-02T07:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1031950#M6292</link>
      <description>&lt;P&gt;Did you try &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic9927.html" target="_self"&gt;template.GetDefinition()&lt;/A&gt; to and then loop through each key value pair in &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic1336.html" target="_self"&gt;CIMFeatureTemplate.DefaultValues&lt;/A&gt;&amp;nbsp;, edit the definition, then call &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic9930.html" target="_self"&gt;template.SetDefinition&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 15:50:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1031950#M6292</guid>
      <dc:creator>KirkKuykendall1</dc:creator>
      <dc:date>2021-03-02T15:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032020#M6294</link>
      <description>&lt;P&gt;Prashant,&lt;/P&gt;&lt;P&gt;Take a look at the following help topics for some concepts and examples to get you started&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Editing#feature-templates" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Editing#feature-templates&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProGuide-Templates" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProGuide-Templates&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;other topics on templates&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Editing#edit-templates" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Editing#edit-templates&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Editing/EditingTemplates" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Editing/EditingTemplates&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 17:58:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032020#M6294</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-02T17:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032295#M6297</link>
      <description>&lt;P&gt;I'm able to assign values for CIMFeatureTemplate but when I call SetDefinition, values are resetting again and showing empty.&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; IEnumerable&amp;lt;FeatureLayer&amp;gt; featLayers = theMap.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;();
foreach (FeatureLayer item in featLayers)
{
 foreach (var template in MappingExtensions.GetTemplates(item))
  {
   CIMFeatureTemplate featTemplate = (CIMFeatureTemplate)template.GetDefinition();
   featTemplate.DefaultValues["fieldname"] = "SomeValue"; //Values are updated
   template.SetDefinition(featTemplate); //template.Defaultvlaues are empty here
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 01:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032295#M6297</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-03-03T01:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032310#M6298</link>
      <description>&lt;P&gt;This works for me:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async Task UpdateTemplates(FeatureLayer fLayer)
{
    // set the default value for the DisplayName field 
    // to whatever the name of the template is
    await QueuedTask.Run(() =&amp;gt;
    {
        var layerDef = fLayer.GetDefinition() as CIMFeatureLayer;
        var featTemplates = layerDef.FeatureTemplates?.ToList();
        if (featTemplates == null)
            featTemplates = new List&amp;lt;CIMEditingTemplate&amp;gt;();

        foreach (var t in featTemplates.OfType&amp;lt;CIMFeatureTemplate&amp;gt;())
        {
            if (t.DefaultValues == null)
                t.DefaultValues = new Dictionary&amp;lt;string, object&amp;gt;();
            Debug.Print(t.Name);
            foreach (var kvp in t.DefaultValues)
                Debug.Print($"\t {kvp.Key} : {kvp.Value}");
            t.DefaultValues["DisplayName"] = t.Name;
        }
        layerDef.FeatureTemplates = featTemplates.ToArray();
        fLayer.SetDefinition(layerDef);
    });
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Mar 2021 04:17:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032310#M6298</guid>
      <dc:creator>KirkKuykendall1</dc:creator>
      <dc:date>2021-03-03T04:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032315#M6299</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;KirkKuykendall1,&lt;/P&gt;&lt;P&gt;Perfectly working.. used t.Defaultvalues["FieldName"] = "SomeValue" to update attributes in collection.&lt;/P&gt;&lt;P&gt;Really appreciate your help,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 05:26:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032315#M6299</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-03-03T05:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set attributes in featurelayer edittemplate</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032316#M6300</link>
      <description>&lt;P&gt;Thank you SeanJones,&lt;/P&gt;&lt;P&gt;Really helpful resources to understand templates in depth.&lt;/P&gt;&lt;P&gt;-Prashant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 05:27:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/set-attributes-in-featurelayer-edittemplate/m-p/1032316#M6300</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-03-03T05:27:19Z</dc:date>
    </item>
  </channel>
</rss>

