How to find default value defined on field

480
2
10-02-2019 03:15 PM
JoeHershman
MVP Regular Contributor

We have some layers created in AGOL.  These table  have default values that are assigned to the field.  These are not assigned to the feature template so they do not show up as PrototypeAttributes.  Is it possible to find these values?  Right now the only thing I can see is to parse the service definition json, which is more involved then I would like

Thanks

-Joe

2 Replies
dotMorten_esri
Esri Frequent Contributor

If you just don't set the attributes and add it to the table, won't the feature get its default values once you pull it back out of the table?

0 Kudos
JoeHershman
MVP Regular Contributor

When I try to add the row to the table I get a null exception because a non-null field is not being set to the default value.  I have code that loops through the PrototypeAttributes to set all those attributes but there are some that are not included even though they have a default value.  We are using the UPDM 2019 data model not a model we created ourselves

await feature.FeatureTable.AddFeatureAsync(feature);

{Esri.ArcGISRuntime.ArcGISRuntimeException: Cannot extract a null row value. Call is_null to check.: lifecyclestatus cannot be null. Encountered on feature with ID of -9223372036854775808.  at Esri.ArcGISRuntime.ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException) [0x00013] in <08b2a841d4d34b638c69bf9e3f231de6>:0   at RuntimeCoreNet.GeneratedWrappers.Interop.CheckError (System.IntPtr errorHandle, System.Boolean throwOnFailure, System.Runtime.InteropServices.GCHandle wrapperHandle) [0x0002e] in <08b2a841d4d34b638c69bf9e3f231de6>:0   at RuntimeCoreNet.GeneratedWrappers.CoreTask.Get () [0x00019] in <08b2a841d4d34b638c69bf9e3f231de6>:0   at Esri.ArcGISRuntime.Internal.CoreTaskExtensions+TaskCompletedCallbackHandler`1.OnCompleted (System.Object sender, System.EventArgs e) [0x00034] in <08b2a841d4d34b638c69bf9e3f231de6>:0 --- End of stack trace from previous location where exception was thrown ---  at Esri.ArcGISRuntime.Internal.CoreTaskExtensions+TaskCompletedCallbackHandler`1.CreateInternal (RuntimeCoreNet.GeneratedWrappers.CoreTask task, System.Threading.CancellationToken cancellationToken) [0x0007f] in <08b2a841d4d34b638c69bf9e3f231de6>:0   at Esri.ArcGISRuntime.Data.FeatureTable.AddFeatureAsync (Esri.ArcGISRuntime.Data.Feature feature) [0x0008f] in <08b2a841d4d34b638c69bf9e3f231de6>:0   at Mobile.AsBuilt.Framework.EditTools.EditBaseViewModel.CompleteFeatureSubmitted (Mobile.AsBuilt.Framework.Events.FeatureSubmittedEventArgs args) [0x000cb] in D:\repos\ramtech-client-png\as-built-xamarin\src\Mobile.AsBuilt.Framework\EditTools\EditBaseViewModel.cs:584 }

{
      "name" : "lifecyclestatus", 
      "type" : "esriFieldTypeSmallInteger", 
      "alias" : "Life Cycle Status", 
      "sqlType" : "sqlTypeOther", 
      "nullable" : false, 
      "editable" : true, 
      "domain" : 
      {
        "type" : "codedValue", 
        "name" : "Pipeline_Lifecycle_Combined", 
        "codedValues" : [
          {
            "name" : "Unknown", 
            "code" : 0
          }, 
          {
            "name" : "Proposed", 
            "code" : 1
          }, 
          {
            "name" : "Approved", 
            "code" : 2
          }, 
          {
            "name" : "Proposed and Approved", 
            "code" : 3
          }, 
          {
            "name" : "Under Construction", 
            "code" : 4
          }, 
          {
            "name" : "Approved and Under Construction", 
            "code" : 6
          }, 
          {
            "name" : "Proposed, Approved and Under Construction", 
            "code" : 7
          }, 
          {
            "name" : "In Service", 
            "code" : 8
          }, 
          {
            "name" : "In Service and Under Construction", 
            "code" : 12
          }, 
          {
            "name" : "In Service, Under Construction, and Approved", 
            "code" : 14
          }, 
          {
            "name" : "In Service, Under Construction, Approved and Proposed", 
            "code" : 15
          }, 
          {
            "name" : "To Be Retired", 
            "code" : 16
          }, 
          {
            "name" : "In Service and To Be Retired", 
            "code" : 24
          }, 
          {
            "name" : "Abandoned", 
            "code" : 32
          }, 
          {
            "name" : "Retired", 
            "code" : 64
          }, 
          {
            "name" : "Removed", 
            "code" : 128
          }, 
          {
            "name" : "Out of Service", 
            "code" : 256
          }
        ]
      }, 
      "defaultValue" : 8
    }
0 Kudos