Clearing text field based on selection on another field

I’ve searched this and was unable to find an answer.

I have a text field that displays based on the selection of another Enum field. The parameters of the Enum are “Pass”, “Review”, and “N/A”. The desired behavior is to clear the text field whenever “N/A” is selected from the Enum field.

How may I achieve that?

Solved Solved
0 17 1,876
  • UX
1 ACCEPTED SOLUTION

Thank you.

I believe even if the initial value for the text column is set as blank(" ") when the enum default is “N/A”, once the column becomes visible on “Pass” or “Review” enum selections and if the user writes some description in the text field, one cannot go back to initial vlaue of blank description in text field even if user again selects “N/A”

So you may need a form save event action to set the text field to blank when the form is saved with enum selection as “N/A” to clear any text that user might have written in the text field.

View solution in original post

17 REPLIES 17

Hi! Welcome to the Community!

To “clear” a field, simply set it to the empty string - e.g. “” : (double-quotes with no spaces).

If need to know how/where you would do this then you simply include an expression inside of the Text field, either in its Initial Value property or in the App Formula property. The expression would look like this:

IF([Enum] = "N/A", "", [_THIS])

[Enum] is your enum column. [_THIS] is an AppSheet keyword that refers to the current column which, in this expression, will simply keep the current value of the [Text] column as is when [Enum] is anything other than “N/A”.

I hope this helps!!

Function looks fine, but it doesn’t work. I tried applying the expression first in the text field’s Initial Value property, then in the App Formula property; neither worked. Changing the selection on the Enum to anything else reveals the old text value.

I think you need to put a similar expression into the Reset On Edit field for the text column, and make sure there is nothing in the Initial Value field.

[Enum] = “N/A”

Still no success. Something that looks so easy, yet no joy.

@Peter_Kalu Sorry, I’ve been away for a long holiday weekend with the family and had no internet nor cellular.

Did you get this figured out?

As @Suvrutt_Gurjar has pointed out, the end solution depends on your desired functionality. Since the Text field is one you wish for a user to be able to edit but then hide and clear out the text when the Enum column is set to "N/A, then an action attached the Form Saved property, as suggested by @Suvrutt_Gurjar, is the best solution.

I believe you may wish to add, what you mean by this. Make the text field disappear ( meaning not to display the field itself) or to make it appear as blank with no text when “N/A” is selected. Also in case of other Enum selections, should it display some predetermined text.

I’ve currently setup the text field to only display when Enum is not “N/A”. So, instead of just making it invisible if N/A is selected, I also want to clear the text field. So, whenever Enum selection changes to something else, the user should get an empty text field - regardless of what was there before.

Thank you. You mean empty text field that user can edit ?

Yes.

Thank you, so is this understanding correct that the text field should display some predetermined text when the selection is “Pass” or “Review” and it should be empty and user editable in case of enum selection of “N/A”

The initial value and state of the text field is empty and invisible. The default value of the Enum is “N/A”. Text field has no predetermined text. It is editable and visible when either “Pass” or “Review” is selected in the enum. If user switches enum back to N/A, then clear and hide the text field. So, if they switch back Pass/Review, they get a clean slate.

Thank you.

I believe even if the initial value for the text column is set as blank(" ") when the enum default is “N/A”, once the column becomes visible on “Pass” or “Review” enum selections and if the user writes some description in the text field, one cannot go back to initial vlaue of blank description in text field even if user again selects “N/A”

So you may need a form save event action to set the text field to blank when the form is saved with enum selection as “N/A” to clear any text that user might have written in the text field.

Thank you. How would I set it up to automatically run when form is saved?

Yes. You could add it in the form view setting as below, so every time the form save event takes place, the action is auto invoked.

Edit: https://help.appsheet.com/en/articles/1013286-view-events

Thank you again, I’ll play with the sample app.

Sure, I may mention here that the sample app is just to refer to know how event actions automatically invoke on form save event.
The type of action itself in the sample app is different ( go to another view type) than the one you will need (set values of some columns in this row)

Top Labels in this Space