<?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 How do you write to a feature layer's field? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270556#M9564</link>
    <description>&lt;P&gt;I know how to create a new field in an existing feature class, but if I have a list of calculated outputs, how do I write those outputs in the new fields? Can I use the index of the feature class's table to write the values row by row using the common index? Is there a community sample that you recommend?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone!&lt;/P&gt;</description>
    <pubDate>Wed, 22 Mar 2023 18:41:41 GMT</pubDate>
    <dc:creator>tzz_12</dc:creator>
    <dc:date>2023-03-22T18:41:41Z</dc:date>
    <item>
      <title>How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270556#M9564</link>
      <description>&lt;P&gt;I know how to create a new field in an existing feature class, but if I have a list of calculated outputs, how do I write those outputs in the new fields? Can I use the index of the feature class's table to write the values row by row using the common index? Is there a community sample that you recommend?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 18:41:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270556#M9564</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-03-22T18:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270581#M9567</link>
      <description>&lt;P&gt;Using a cursor, this is how I calculated the field "PS_Count" in the FeatureClass "featureClass" to 1.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;QueryFilter queryFilter = new() { WhereClause = "1=1" };
EditOperation editOperation = new();
await QueuedTask.Run(() =&amp;gt;
{
  using RowCursor rowCursor = featureClass.Search(queryFilter, false);
  while (rowCursor.MoveNext())
  {
    using Row record = rowCursor.Current;
    editOperation.Modify(record, "PS_Count", 1);
  }
});
if (!await editOperation.ExecuteAsync()) MessageBox.Show(editOperation.ErrorMessage);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other way you can do this is with the GeoProcessing Tool&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IGPResult GPResult = await CalculateFeatures(featureClass, "PS_Count", "1", "ARCADE", null, "LONG", GPExecuteToolFlags.AddToHistory);
if (GPResult.IsFailed)
{
  MessageBox.Show("Failed to calculate Count field");
}

public static async Task&amp;lt;IGPResult&amp;gt; CalculateFeatures(FeatureClass InFC, string FieldName, string exp, string exp_type, string code_block, string fieldtype, GPExecuteToolFlags flags)
{
  List&amp;lt;object&amp;gt; arguments = new() {
    InFC, //In Table
    FieldName, //Field
    exp, //Expression
    exp_type, //Expression Type
    code_block, //Code Block,
    fieldtype, //Field Type
  };
  IGPResult result = await Geoprocessing.ExecuteToolAsync("management.CalculateField", Geoprocessing.MakeValueArray(arguments.ToArray()), null, null, null, flags);
  return result;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 19:27:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270581#M9567</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-03-22T19:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270666#M9569</link>
      <description>&lt;P&gt;The &lt;A href="https://github.com/arcgis/arcgis-pro-sdk/wiki/ProConcepts-DDL#adding-or-removing-fields" target="_self"&gt;DDL API&lt;/A&gt; can create a new field to store calculated results, "CalculateResults," in an existing feature class.&lt;/P&gt;&lt;P&gt;Then, iterate rows and set the calculated value on the new field. For the&amp;nbsp;&lt;A href="https://github.com/arcgis/arcgis-pro-sdk/wiki/proconcepts-CoreHost" target="_self"&gt;CoreHost application&lt;/A&gt;, use geodatabase.ApplyEdits to update the row with a calculated value as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (FeatureClass featureClass = geodatabase.OpenDataset&amp;lt;FeatureClass&amp;gt;(featureClassName))
{
  geodatabase.ApplyEdits(() =&amp;gt;
  {
   // Search and iterate all rows
	using (RowCursor rowCursor = featureClass.Search(null, false))
	{
	  while (rowCursor.MoveNext())
	  {
		using (Row row = rowCursor.Current)
		{
		  // Set results to the new field
		  row["CalculateResults"] = "SetYourValue"
		  row.Store();
		}
	  }
	}
  });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 14:05:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270666#M9569</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2023-03-23T14:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270703#M9570</link>
      <description>&lt;P&gt;Hi Aashis,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help! Can I get your feedback on the two error messages I received using your method.&amp;nbsp; When I tried to set the row field to a OutputList, I received the following error: "The value type is incompatible". When I set the row field with just a single value to see if it works,&amp;nbsp; "row.Store()" had an error message that it cannot be stored in a edit session. Please see my script below. I appreciate your help! Thanks!&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  await QueuedTask.Run(() =&amp;gt;
                {
                    using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(outPath))))
                    {
                        using (FeatureClass FC = geodatabase.OpenDataset&amp;lt;FeatureClass&amp;gt;("FC_name"))
                        {
                            geodatabase.ApplyEdits(() =&amp;gt;
                            {
                                // Search and iterate all rows
                                using (RowCursor rowCursor = FC.Search())
                                {
                                    while (rowCursor.MoveNext())
                                    {
                                        using (Row row = rowCursor.Current)
                                        {
                                            // Set results to the new field
                                            //incompatible type error 
                                            row["SD"] = OutputList; 
                                            row.Store(); //edit mode error
                                        }
                                    }
                                }

                            });
                        }
                    }
                });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 02:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270703#M9570</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-03-23T02:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270858#M9571</link>
      <description>&lt;P&gt;The error message&amp;nbsp;&lt;SPAN&gt;"The value type is incompatible" is referring to the data type of the database column and the datatype of the OutputList variable.&amp;nbsp; Your code snippet doesn't show what types we are dealing with, but in general when you update column values in a database table (or feature class) you can only assign the appropriate matching datatype.&amp;nbsp; &amp;nbsp;Take for example this table:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1679578647443.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66067iAB2CD1E5423E6921/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1679578647443.png" alt="Wolf_0-1679578647443.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have the DataTypes of Geometry, Double and Text.&amp;nbsp; &amp;nbsp;So when i update those column values i can only assign a geometry (here even the geometry type point, line, polygon has to match) value, double value or a string value to those columns.&amp;nbsp; Judging by the name 'OutputList' you probably store some type of list of strings or numbers and there is no geodatabase column datatype that supports lists (or arrays).&amp;nbsp; You could store a short list as a comma separated list of strings in a text field, but you have to watch out for character limits on text fields.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 13:46:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270858#M9571</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-03-23T13:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270868#M9572</link>
      <description>&lt;P&gt;See Wolf's comment below and also set the recycling cursor to false.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (RowCursor rowCursor = featureClass.Search(null, false))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 14:15:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1270868#M9572</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2023-03-23T14:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do you write to a feature layer's field?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1273218#M9580</link>
      <description>&lt;P&gt;Hi Wolf &amp;amp; Aashi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help! I was thinking since I have multiple new calculated result fields for each row. I can create a separate variable for each calculated values, instead of joining them together as a list. How can I create a method in C# that will output multiple values, without making it a list or tuple?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 20:33:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-you-write-to-a-feature-layer-s-field/m-p/1273218#M9580</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-03-30T20:33:29Z</dc:date>
    </item>
  </channel>
</rss>

