Select to view content in your preferred language

Minimize Field Maps form Group when all fields have a value

843
3
Jump to solution
05-09-2022 10:52 AM
OliverIshmael
Frequent Contributor

I have a Field Maps form with several Groups of fields. Using conditional visibility I only show users the next relevant question when they make an answer. When the user has added a value to each field in the Group, I would like it to be minimized so that the user can see the questions in the next Group with the minimum of screen scrolling.

Presumably this can be achieved using conditional visibility on input type: Group

Please can someone show me the Arcade to do this?

2 Solutions

Accepted Solutions
RhettZufelt
MVP Notable Contributor

I think you could do this by putting a conditional expression on the group where if the values in the group are not empty, then hide the group.

HOWEVER........

Although, this is a great idea and would make many workflows much easier, the way Field Maps currently works, if you populate data (or have existing data) in a field that gets "Conditionally" hidden (whether in a group or not),  all the data will be nulled out for those fields on hide.

So, basically, at this point, No, as it would "undo" all the previous values entered.

Hopefully future versions will allow us to determine if it keeps values vs. deleting them, but for now.......

R_

 

View solution in original post

0 Kudos
RhettZufelt
MVP Notable Contributor

Upon further testing, it appears that if you include a field you want to hide in the expression, it will NOT get evaluated until you hit the submit the button.  So this option won't work as it keeps the group open until you hit submit.  Then, you can briefly see it clear all the values and then hide.  One would think it could evaluate based on this field once you click out of it, as it now has a value, but apparently not.

If the field is not included in the expression, it will evaluate it as soon as you enter any data into that field.

So, would probably need to move the "last" question of the group just below the group itself.  That way, when they answer it, will hide all the values above it.

So, if my form has "Type", "Color", "Size" as the fields I want to have in a group, I could put the first two in the group, and "Size" just below it. (or just assign the conditional statement to the first two and not have them in a group).

Then, apply a conditional statement to the first two that hides them if "Size" is populated.

 

IsEmpty($feature["Size"])

 

Remember, if the expression evaluated to "True", it will show the field(s).

Unfortunately, you will not be able to hide the "Size" field since it is in the expression, will only evaluate/hide it when you hit submit.

If you want to test will all three, just use && (arcade for "and"):

 

IsEmpty($feature["Size"]) && IsEmpty($feature["Type"]) && IsEmpty($feature["Color"])

 

This should get you started for testing.  But remember, as per the documentation:

Note:

If the expression evaluates to false and the form element becomes hidden in the form, the value for the field is cleared. If a group form element becomes hidden, all values it contains are cleared.

As you can see, by design, the conditional visibility is not really functional for this use.  Pretty much only relevant when there are fields that don't apply to the added/edited feature.

So, in your case, you may be better off having the fields hidden when empty, and just show the fields you want populated based on answer to previous field.  (and keep them visible so it doesn't delete it).

There has been developer discussion about having a way to toggle whether or not the field gets deleted, but have not heard anything on progress of this option.  Maybe in the future, the conditional visibility will actually be useful in real life scenarios.

 

R_

 

View solution in original post

3 Replies
RhettZufelt
MVP Notable Contributor

I think you could do this by putting a conditional expression on the group where if the values in the group are not empty, then hide the group.

HOWEVER........

Although, this is a great idea and would make many workflows much easier, the way Field Maps currently works, if you populate data (or have existing data) in a field that gets "Conditionally" hidden (whether in a group or not),  all the data will be nulled out for those fields on hide.

So, basically, at this point, No, as it would "undo" all the previous values entered.

Hopefully future versions will allow us to determine if it keeps values vs. deleting them, but for now.......

R_

 

0 Kudos
OliverIshmael
Frequent Contributor

Hey Rhett, so I can test this out for myself, are you able to provide me with the Arcade that I need to hide the group?

Many thanks

0 Kudos
RhettZufelt
MVP Notable Contributor

Upon further testing, it appears that if you include a field you want to hide in the expression, it will NOT get evaluated until you hit the submit the button.  So this option won't work as it keeps the group open until you hit submit.  Then, you can briefly see it clear all the values and then hide.  One would think it could evaluate based on this field once you click out of it, as it now has a value, but apparently not.

If the field is not included in the expression, it will evaluate it as soon as you enter any data into that field.

So, would probably need to move the "last" question of the group just below the group itself.  That way, when they answer it, will hide all the values above it.

So, if my form has "Type", "Color", "Size" as the fields I want to have in a group, I could put the first two in the group, and "Size" just below it. (or just assign the conditional statement to the first two and not have them in a group).

Then, apply a conditional statement to the first two that hides them if "Size" is populated.

 

IsEmpty($feature["Size"])

 

Remember, if the expression evaluated to "True", it will show the field(s).

Unfortunately, you will not be able to hide the "Size" field since it is in the expression, will only evaluate/hide it when you hit submit.

If you want to test will all three, just use && (arcade for "and"):

 

IsEmpty($feature["Size"]) && IsEmpty($feature["Type"]) && IsEmpty($feature["Color"])

 

This should get you started for testing.  But remember, as per the documentation:

Note:

If the expression evaluates to false and the form element becomes hidden in the form, the value for the field is cleared. If a group form element becomes hidden, all values it contains are cleared.

As you can see, by design, the conditional visibility is not really functional for this use.  Pretty much only relevant when there are fields that don't apply to the added/edited feature.

So, in your case, you may be better off having the fields hidden when empty, and just show the fields you want populated based on answer to previous field.  (and keep them visible so it doesn't delete it).

There has been developer discussion about having a way to toggle whether or not the field gets deleted, but have not heard anything on progress of this option.  Maybe in the future, the conditional visibility will actually be useful in real life scenarios.

 

R_