I have a variable length field of data that needs to be validated.
Is there any way to iterate over data? For example, is there some sort of for loop, doโฆuntil, etc? If no, as I suspect, how could you handle scenario below?
Example Psuedo Code, step 3 is either a or b, not both:
TIA for any assistance you may be able to provide.
erik
Solved! Go to Solution.
Oh yeah, youโre talking about nesting. All day.
If(true=false,
"Wait...what?!?!",
switch([Some_Column],
"1", "first option",
"2", "second",
if("nothing"="something",
"wow!!!!",
"the end")))
As long as you keep track of where youโre at in the arguments of whatever expression youโre on, and close all the parenthesis, you can stack things so theyโre crazyโฆ
But for what youโre wanting to do, since youโll ALWAYS want these characters to be removed - I wouldnโt bother with the condition, just nest the substitutes.
Thereโs no looping like that, something like a FOR() statement???
But you can do bulk actions, and you can create an action that would take your list of records and run your validation action over them.
First create an individual action for each of your validation steps.
Next, put those actions in a Group action in the order you wish them to process.
Finally, create the โexecute an action on a set of rowsโ action that calls your grouped action.
I guess in a way, the โData: execute an action on a set of rowsโ is kinda like a FOR() statementโฆ
FOR each of the rows, do THIS action.
Well, if I have a text field, I donโt know how long the string it contains is when building the action. Say a user enters 5 characters - the action will need to evaluate 5 times, once for each character. Next time I might need to check on 25 characters. How would I setup an action that can apply a test to any given number of characters/words without some sort of looping construct?
I cannot think of a way that would allow you to do this. I would suggest to look for a way to design the data differently.
I agree with @Bahbus, you wonโt be able to do something like that.
Perhaps if you gave us some clues as to what youโre trying to do, Iโm sure someone here will have some ideas.
Not sure if this helps, but did you consider to use Contains() expression?
Thanks @Steve. These two posts are related, as you surmised. Thanks @MultiTech_Visions as well for a solution (other thread) that pointed me in the right direction.
Follow up question: Is there a way to use an IF() construct in such a way that multiple actions are assigned to the true and false events? Example:
IF( some expression,
true do something AND do something AND do something,
false do other thing AND another thing
)
Are the expressions used for true and false limited to a single action?
Think of it more like โthe space in the formulaโ needs either True or False - meaning, the place you enter the conditions in the formula - however you get there is up to you.
IF( true
IF( true = true
IF( and(true = true, false = false)
You can have as many conditions inside the condition space, as long as it ultimately results in either true or false.
@MultiTech_Visions I understand about setting multiple conditions using AND, OR, etc. What I am asking about is the โthen doโ and โelse doโ parts.
More detailed example:
< conditional >
IF(
OR(
contains([MAC Address Entry], โgโ),
contains([MAC Address Entry], โhโ),
contains([MAC Address Entry], โiโ) ),
โฆ
< then do >
(SUBSTITUTE([MAC Address Entry], โgโ, โโ))
(SUBSTITUTE([MAC Address Entry], โhโ, โโ))
(SUBSTITUTE([MAC Address Entry], โiโ, โโ)),
โฆ
< else do >
SOMETHING ELSE
SOMETHING ELSE
I hope that makes the question a bit clearer. Thanks again for imparting your knowledge on us noobs!
I have tried the following in the formula for a field, but it always hits the first one (g) and skips the second (h). So now Iโm trying to see if I can stack actions in the < then do > section of the expression.
< only first condition happens >
IF(
contains([MAC Address Entry], โgโ),
(SUBSTITUTE([MAC Address Entry], โgโ), โโ),
([MAC Address Entry])
)
IF(
contains([MAC Address Entry], โhโ),
(SUBSTITUTE([MAC Address Entry], โhโ), โโ),
([MAC Address Entry])
)
Oh yeah, youโre talking about nesting. All day.
If(true=false,
"Wait...what?!?!",
switch([Some_Column],
"1", "first option",
"2", "second",
if("nothing"="something",
"wow!!!!",
"the end")))
As long as you keep track of where youโre at in the arguments of whatever expression youโre on, and close all the parenthesis, you can stack things so theyโre crazyโฆ
But for what youโre wanting to do, since youโll ALWAYS want these characters to be removed - I wouldnโt bother with the condition, just nest the substitutes.
@MultiTech_Visions you rock! Itโs gonna be ugly, but at least I know how to do it now.
Another follow up: is there a way to add comments into a long expression like that? # or // or something tells interpreter to ignore line?
No, unfortunately. We asked for it awhile ago, but due to how things are parsed (especially with workflows and templates) thereโs a limitation to that.
Also, when using a literal double quote, open/close parenthesis, etc is there a way or need to escape certain characters?
SUBSTITUTE([MAC Address Entry], โ< double quote >โ, โโ)
should it be like this: SUBSTITUTE([MAC Address Entry], โโ", โโ)
or like this: SUBSTITUTE([MAC Address Entry], " \ " ", โโ) ignoring extra spaces
As long as things are contained inside the double quotes, you can enter any string you wish - even single quotes for apostrophes.
So:
โCanโt figure it outโ = Canโt figure it out
AppSheet is smart about things like that.
You canโt include double quotes inside your double-quoted-text though, for that you can use single quotes:
'Then she said, โSomething wild!!!โ โ = Then she said, โSomething wild!!!โ
OK, it is so close now.
I have found one seeming exception to the smart double quotes: single quote. I have not been able to find a way to test against a single quote
IF(
ISNOTBLANK([MAC Address Entry]),
SUBSTITUTE([MAC Address Entry], " โ ", โโ), โblankโ) < extra spaces added for clarity >
This does not work. Insert anything other than a single quote inside the SUBSTITUTE line and it works great. Do you know of a way to check against a single quote, or is this possibly a bug?
Edit: I have tried to following patterns for single quote, all of which failed:
< extra spaces added for clarity >
" โ "
โ โ โ
โ " โ " โ < interprets but does function as intended >
" \ โ "
Canโt be done. Itโs a known limitation of the parser library. (Last I brought the issue up.)
Thatโs a bummer. Seems to me that, for a data entry/capture application platform, itโs fairly important to be able to test against any possible character input on a keyboard (or read from OCR, Scanner, etc). Do you know if there is a plan to overcome this limitation?
Iโm sure itโs one of many to-doโs on their ever-growing list, but I imagine will only be part of a larger overall upgrade or overhaul.
I do not know.
User | Count |
---|---|
44 | |
29 | |
24 | |
21 | |
13 |