Default Values not working in Field Maps Mobile

9594
33
Jump to solution
11-15-2021 07:26 AM
KristinThorpe1
Occasional Contributor

I have a hosted feature layer named "Construction" that I am using to show the location of construction site projects. When I add a new point, I want the "Construction Phase" field to default to "Active Site" (aka domain 7). As far as I can tell, the feature layer is set up correctly to assign this default value. If I use Map Viewer to add a new point, the Construction Phase defaults to "Active Site" like I want, but when I use Field Maps mobile, the default is not assigned. This work flow will most likely be used with Field Maps mobile and will create issues down the road if the default value is not set. 
Am I missing something? Why is the default value not being set in Field Maps but working everywhere else?

33 Replies
mikAMD
by
Occasional Contributor III

@AaronCole1, thanks your help!

You pointed me in the right direction. I'm using a hosted feature service however, so I could not do the changes you mentioned in Pro. I continued searching, found this thread and then managed to add a template through the API.

I'll post my code in that thread for anybody looking for a similar solution.

However now I wonder what is the use of the default value in the layer definition? What is the difference between the template and the default value ? 🤔

 

Thanks!

0 Kudos
AaronCole1
Occasional Contributor

That's great, happy to provide some direction, even if not the solution. I stumbled with this for a little while.

I was able to set a default value for a hosted feature service in Pro just now. I wonder if that is a recently added capability?

Attribute default values are a property of a specific feature template. You could create multiple templates with different default values for different situations. You can also select the default tool for editing, among other things I'm sure.

DanMakridakis
New Contributor III

For anyone still dealing with this issue. I've found the cause and workaround when publishing from Pro to ArcGIS Server.

If the feature template inherits the default values from the feature class schema, even though it appears in the Pro feature template, it will not be pushed into the published service and therefore will not work in Field Maps. As others have mentioned, for it to publish with the service, you need to trick it into thinking the default is uniquely set for that feature template. However, you don't need to do as many steps as others have suggested (change, save, change back, save, republish). You can simply change each default in the feature template properties to anything else, and then change it back to the default before closing the properties. You can do this to all of your feature templates before saving the project and re-publishing the service.


One trick to determine if a default value is going to publish, is to look for a Grey bar next to that field name while in the feature template properties. If there is a Grey bar next to the field, then it's recognized as a unique default and will publish. When tricking it, you want it to appear with a Green bar next to the field, meaning it thinks it has changed. After accepting the properties the Green bar will change to Grey. If the bar next to the field is Blue, then it will not publish. If you to click on a default drop down and select the same value, you will see the field remains Blue because it knows it is the same value and nothing changed. This is why you must first change it to something else and then back to trick it (no need to close in between).

In the example below, 'Enabled' and 'AncRole' have Green bars next to them indicating they have been altered since opening the properties (inherited default was changed to something else and then back to the default). After closing and reopening the properties, they will have a Grey bar next to them, as is seen next to 'Segment' and 'GIS Status' which were previously changed. 'Owner' has a Blue bar next to it even though it has a default value, as do all the field without default values. In the current state, 'Owner' would not have the default published with the service, but the other 4 fields will.

DanMakridakis_0-1707325452950.png

 

AlexVideka
New Contributor III

Amazing find Dan! This is the much more feasible workaround while the bug still exists. Worked perfectly for me!