Conditional visibility erases attribute values when editing existing features

858
11
Jump to solution
12-17-2020 09:25 AM
BrendanMadden
New Contributor II

Hello,

I'm trying to use conditional visibility in a form on a map that will be used only to modify existing features, and I've run into an issue where attributes with conditional visibility rules applied have their values deleted when visibility changes. An example of what I'm trying to do: I have a field for the number of PTZ cameras at a location, with a numeric range of 0 - 2. I then have fields for make/model/type for camera 1 and camera 2. If there are 0 PTZ cameras, I don't want any of those additional fields to show. If the number of PTZ's is 1, I want camera 1's make/model/type fields to show, but not camera 2's. Many of the features already have camera 1 data filled in for make/model/type. The problem is, if I change the value of "number of PTZ's" from 1 to 2, the conditional visibility rule briefly hides camera 1's fields, then re-shows them (along with camera 2's). That brief hiding clears the values that were entered for camera 1's make/model/type, which is not what I would expect to happen and is not great for the user. Is this expected behavior? I don't see why existing data in a field should be deleted when the field is hidden; it should just be hidden. I can get around this by just not using conditional visibility rules, but the form has a lot of fields and it's kind of an ideal use of that smart form capability. I like Field Maps so far and I'm excited about the possibilities it offers, so I'm hoping this can be changed.

0 Kudos
2 Solutions

Accepted Solutions
by Anonymous User
Not applicable

Hi @BrendanMadden 

Thank you for that information. I added an issue on our end to continue investigating this behavior using the use-case you shared.

I also wanted to provide a potential workaround for you as well. 

If the existing expressions for the Cam1 fields are modified in the following way, the fields will remain visible when the field user edits the value from 1 to 2, thereby keeping the existing values:

$feature["FIELD_PTZ_QUANTITY"] > 0 || IsEmpty(null)

 

Please let me know if you have any questions.

-Kevin

 

View solution in original post

BrendanMadden
New Contributor II

Hi @KevinBurke,

Thanks for that suggestion! I had to tweak it slightly to get it to work, because using "IsEmpty(null)" was making all the fields show all the time. Here's what I did to make it work:

$feature["FIELD_PTZ_QUANTITY"] > 0 || IsEmpty($feature["FIELD_PTZ_QUANTITY"])

I also modified my camera 2 fields a bit to be >= 2 rather than just == 2. Even though the domain range on the field is 0 - 2, if someone did enter a number greater than 2 it would have erased camera 2's field values. This way, the fields will still display in that scenario.

Thanks so much for your help with this! It has gotten me to think more about how to properly build the Arcade expressions for conditional visibility, and the workaround you suggested should work just fine.

View solution in original post

11 Replies
by Anonymous User
Not applicable

Hi @BrendanMadden 

Thank you for that feedback.

I would like to try and understand the form/expression setup a bit more.

I understand the fields for make/model/type only display when the field for # of PTZ cameras is 1 or 2 and hidden when 0. 

In general the way the app functions with respect to conditional visibility expressions is that the expression for a given field is evaluated with each key-stoke on the keyboard. Therefore in this case, the field has an existing value of 1 which keeps the fields visible > this is then deleted during editing which makes the value temporarily null which hides the fields since the expression is now false > the fields are then displayed again when the user enters 2. It's during the action of the fields being hidden where any existing values are cleared. 

Would you be able to share the expression you wrote? 

Thank you

-Kevin

0 Kudos
BrendanMadden
New Contributor II

Hi Kevin,

Yes, that's exactly right. When the fields are hidden by deleting the 1 and then entering 2, the values that had previously been filled in camera 1's fields are deleted. Here are the expressions I am using on the camera 1 and 2 fields ("FIELD_PTZ_QUANTITY" is the field with 0, 1, or 2):

Camera 1 make/model/type: 

$feature["FIELD_PTZ_QUANTITY"] > 0

 

Camera 2 make/model/type:

$feature["FIELD_PTZ_QUANTITY"] == 2
0 Kudos
by Anonymous User
Not applicable

Hi @BrendanMadden 

Thank you for that information.

- Do the same Make/Model/Type fields apply to both Camera 1 and Camera 2 or do they have separate fields? i.e. 6 fields in total between both cameras?

- For the expressions you shared above, and related to the previous question, the expression for camera 1 is applied three times for the Make/Model/Type fields and the same applies for the camera 2 expression for it's 3 fields? Is that correct?

Thank you

-Kevin

0 Kudos
BrendanMadden
New Contributor II

Hi @Anonymous User,

- Camera 1 and Camera 2 have their own make/model/type fields (6 total).

- That's correct, each Camera 1 field has the Camera 1 expression applied, and each Camera 2 field has the Camera 2 expression applied.

0 Kudos
by Anonymous User
Not applicable

Hi @BrendanMadden 

Thank you for that information.

Now that I've gotten more clarification on the setup, I have a few more questions regarding the expected behavior for additional clarification.

- When switching from 1 to 2 for the # of PTZ cameras, all 6 fields are now displayed for both cameras and all the fields are blank. Is that correct?

- From the first question, all the fields being displayed is expected just not the part of the missing values for camera 1. Is that correct?

- The values for make/model/type can be different for each camera? The quantity of the cameras is more that just the amount of cameras using the same make/model/type but point to specific cameras that may use different specs? I am just trying to make sure I understand why each camera has separate fields if they can be of the same make/model/type. 

In general the behavior with the clearing of the values when fields are made hidden does have it merits for certain workflows where those values are no longer valid per the previously selected/entered values upstream in the form, so in that respect this is working as expected. With that being said however, we're currently still evaluating when it's appropriate for values to be cleared for hidden fields. For the time being with your current workflow, I am trying to determine how we may be able to workaround this behavior to achieve the expected results. 

Thank you for that clarification and information.

-Kevin

0 Kudos
BrendanMadden
New Contributor II

Hi @Anonymous User,

- Yes, when changing the value from 1 to 2, all six fields are visible and blank.

- Correct - I would expect all six fields to be visible, but not that Camera 1's fields would be blank (assuming they had already been populated, which they generally are).

- The quantity refers to the total number of PTZ cameras at a location (0, 1, or 2 max). Cameras 1 and 2 could have the same or different makes/models/types.

Thanks a lot for that explanation, that makes sense. I definitely appreciate there are situations where clearing the fields when they are hidden makes sense. In my opinion though, I do think having some way to enable/disable that behavior would be really helpful. I could see situations where a user accidentally changes a field that is tied to conditional visibility and then loses data that they did not intend to. Canceling the update and restarting would be an option, but in my case this is a pretty long form and the user may end up having to spend a lot of time re-entering data unnecessarily. With the current behavior, I think my best option is to not use conditional visibility on those fields for now. It's not a deal-breaker, just a bit longer of a form.

I think the behavior as it is now makes a lot of sense when creating new features. My workflow in this case is modifying existing features, and that's where I see the current behavior being potentially problematic.

Thanks for working through this with me, I appreciate it!

by Anonymous User
Not applicable

Hi @BrendanMadden 

Thank you for that information. I added an issue on our end to continue investigating this behavior using the use-case you shared.

I also wanted to provide a potential workaround for you as well. 

If the existing expressions for the Cam1 fields are modified in the following way, the fields will remain visible when the field user edits the value from 1 to 2, thereby keeping the existing values:

$feature["FIELD_PTZ_QUANTITY"] > 0 || IsEmpty(null)

 

Please let me know if you have any questions.

-Kevin

 

BrendanMadden
New Contributor II

Hi @KevinBurke,

Thanks for that suggestion! I had to tweak it slightly to get it to work, because using "IsEmpty(null)" was making all the fields show all the time. Here's what I did to make it work:

$feature["FIELD_PTZ_QUANTITY"] > 0 || IsEmpty($feature["FIELD_PTZ_QUANTITY"])

I also modified my camera 2 fields a bit to be >= 2 rather than just == 2. Even though the domain range on the field is 0 - 2, if someone did enter a number greater than 2 it would have erased camera 2's field values. This way, the fields will still display in that scenario.

Thanks so much for your help with this! It has gotten me to think more about how to properly build the Arcade expressions for conditional visibility, and the workaround you suggested should work just fine.

KevinBurke
Esri Contributor

@BrendanMadden that's awesome! Glad you were able to further manipulate my suggested workaround to better suit the field workflow.

Thanks

-Kevin 

0 Kudos