<?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 .net SDK - Adding/Creating a feature... default values? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/net-sdk-adding-creating-a-feature-default-values/m-p/36125#M177</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to figure out how to use a field's default value when using the .net c# SDK when adding a feature.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArcGIS, in the Feature Class properties, each field can have a default value:&lt;BR /&gt;&lt;IMG __jive_id="260548" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/260548_fc_properties1611091503.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I can't seem to find the Default Value via the SDK. &amp;nbsp;Here is my code:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var table = new ServiceFeatureTable&lt;BR /&gt; {&lt;BR /&gt; ServiceUri = url,&lt;BR /&gt; OutFields = new OutFields(OutFields.All)&lt;BR /&gt; };&lt;BR /&gt; await GenerateToken(url).ConfigureAwait(false);&lt;BR /&gt; await table.InitializeAsync(table.SpatialReference).ConfigureAwait(false);&lt;BR /&gt; var schemaFields = table.Schema.Fields.ToList();&lt;BR /&gt; var feature = new GeodatabaseFeature(table.Schema)&lt;BR /&gt; {&lt;BR /&gt; Geometry = geometry&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; foreach (var attribute in attributes)&lt;BR /&gt; {&lt;BR /&gt; var field = schemaFields.FirstOrDefault(x =&amp;gt; x.Name.ToLower().Equals(attribute.Key.ToLower()));&lt;BR /&gt; if (field != null)&lt;BR /&gt; {&lt;BR /&gt; feature.Attributes[attribute.Key] = attribute.Value != null ? TranslateField(field, attribute.Value) : null;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; await table.AddAsync(feature);&lt;BR /&gt; &lt;BR /&gt; var result = await table.ApplyEditsAsync(true);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nowhere in the schema field or the feature class is there an option to apply a default value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Nov 2016 18:50:15 GMT</pubDate>
    <dc:creator>brianbullas</dc:creator>
    <dc:date>2016-11-09T18:50:15Z</dc:date>
    <item>
      <title>.net SDK - Adding/Creating a feature... default values?</title>
      <link>https://community.esri.com/t5/developers-questions/net-sdk-adding-creating-a-feature-default-values/m-p/36125#M177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to figure out how to use a field's default value when using the .net c# SDK when adding a feature.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArcGIS, in the Feature Class properties, each field can have a default value:&lt;BR /&gt;&lt;IMG __jive_id="260548" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/260548_fc_properties1611091503.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I can't seem to find the Default Value via the SDK. &amp;nbsp;Here is my code:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var table = new ServiceFeatureTable&lt;BR /&gt; {&lt;BR /&gt; ServiceUri = url,&lt;BR /&gt; OutFields = new OutFields(OutFields.All)&lt;BR /&gt; };&lt;BR /&gt; await GenerateToken(url).ConfigureAwait(false);&lt;BR /&gt; await table.InitializeAsync(table.SpatialReference).ConfigureAwait(false);&lt;BR /&gt; var schemaFields = table.Schema.Fields.ToList();&lt;BR /&gt; var feature = new GeodatabaseFeature(table.Schema)&lt;BR /&gt; {&lt;BR /&gt; Geometry = geometry&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; foreach (var attribute in attributes)&lt;BR /&gt; {&lt;BR /&gt; var field = schemaFields.FirstOrDefault(x =&amp;gt; x.Name.ToLower().Equals(attribute.Key.ToLower()));&lt;BR /&gt; if (field != null)&lt;BR /&gt; {&lt;BR /&gt; feature.Attributes[attribute.Key] = attribute.Value != null ? TranslateField(field, attribute.Value) : null;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; await table.AddAsync(feature);&lt;BR /&gt; &lt;BR /&gt; var result = await table.ApplyEditsAsync(true);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nowhere in the schema field or the feature class is there an option to apply a default value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 18:50:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/net-sdk-adding-creating-a-feature-default-values/m-p/36125#M177</guid>
      <dc:creator>brianbullas</dc:creator>
      <dc:date>2016-11-09T18:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: .net SDK - Adding/Creating a feature... default values?</title>
      <link>https://community.esri.com/t5/developers-questions/net-sdk-adding-creating-a-feature-default-values/m-p/36126#M178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think i figured it out....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;var table = new ServiceFeatureTable&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;{&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;ServiceUri = url,&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;OutFields = new OutFields(OutFields.All)&lt;/SPAN&gt;&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I am setting out fields to all. If i instead only ask for a couple selected out fields, then the unselected (ones not included in the outfields list) fields will use their default value, if there is one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var table = new ServiceFeatureTable&lt;BR /&gt; {&lt;BR /&gt; ServiceUri = url,&lt;BR /&gt; OutFields = new OutFields(attributes.Select(x=&amp;gt;x.Key)),&lt;BR /&gt; };&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;will use default values when inserting / creating if it's not included in the list of attributes above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 20:07:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/net-sdk-adding-creating-a-feature-default-values/m-p/36126#M178</guid>
      <dc:creator>brianbullas</dc:creator>
      <dc:date>2016-11-09T20:07:00Z</dc:date>
    </item>
  </channel>
</rss>

