Hello.
How do I make appsheet automatically trim whitespace from the beginning and end string of an Input Form text field?
Solved! Go to Solution.
You can do that with an Event Action if you set that action from your Form View.
There is a TRIM() function though there isnโt yet a support article for it.
So how / which constraint would I use TRIM? I want any text that a user inputs to a form to automatically be trimmed for whitespace when the form is being saved.
You can do that with an Event Action if you set that action from your Form View.
Im checking out your suggestion now, but didnt appsheet used to do this?
Let me check this internallyโฆ
Thanks Aleksi!
Just to let you know how I use this: My app tracks the last time a user has updated any info in a record. I dont want them to be able to add a few blank spaces in a field and trick the app into thinking a material change in data has been made.
@David_Joyce I played with this one a little and it seems to filter whitespaces from the end and from the beginning, but not from the middle. If you add one or more spaces but without any real letter or number, it filters all away and then the fieldโs value is blank and it should not show that field in the detail view.
As @Aleski has pointed out, TRIM() does not filter whitespace from the middle of the text. Based on your concern of adding spaces to โtrickโ the app into thinking there was a change, youโll want to keep that in mind.
As for trimming the whitespace, there are a few options:
Trimming Whitespace on Input:
Use validation to determine if there is beginning or ending spaces and if so, make field invalid and show a message that leading and trailing spaces are not allowed. I.e. force the user to enter it correctly.
Use two columns. One for input only and second for the internal app usage that trims spaces.
Trimming Whitespace After Save:
TRIM() does filter extra whitespaces from the middle. That was the whole idea for the TRIM() expression in the beginning.
Thank you for the correction! I do see now that multiple entered spaces in the middle are trimmed to just single one. Leading and trailing spaces are removed entirely!
Example of TRIM()
Trimming whitespace from the end and the beginning is acceptable. If field only contains whitespace, then the behaviour I need is to set it to blank. So far so good
As to my users putting whitespace in the middle of real text, Iโll accept that because there is no way I can see of preventing that.
Good solution @Aleksi, and thanks @WillowMobileSystems
EDIT: Just read your post about TRIM removing extra whitespace from the middle. Excellent!!
Yes you can filter extra whitespaces with an Event Action using TRIM() when the form is saved.
User | Count |
---|---|
41 | |
28 | |
28 | |
23 | |
13 |