I am currently working on an app and I was wondering how (or even if) I can make an “if”-Statement based on variables within an array, without first having to transfer the index to a separate variable.
Yes, you can use the “ARRAYCONTAINS()” function in the Expression Editor to see if an array contains the value of a specific variable. Let’s imagine that you have an array of text values, and you want to see if one of them contains the value in a text variable.
Here is how you would accomplish that in an “If” statement:
I would like ti use above functionality to check if value is already in array. If it is then, message will be shown (Already in array - or something similar) otherwise I will add value to string array.
But unfortunately i cant save expression. At save gives mi an error "Type boolean is not valid in this context.
Bellow are some screenshots what was tried:
Expression seems to be OK. But at save I get above message.
Same happens if I replace variables with fixed array.
Thank you for help.
hello @ermingut, thanks for sharing!! we can certainly help out here.
can you confirm that the Variable
arraySelectedParents is indeed type Array of type Text??
this is the behavior I’m getting on my test App with a Text Array. Trigger:
if you could share a screenshot of the App Variables we can help out here.
Yesterday I tried also with fixed array like ARRAYCONTAINS([‘1’,‘2’,‘3’], ‘1’) and got same error. I tried again just now and code is accepted. Below you can see that variable arraySelectedParents is indeed array.
hello @ermingut, thanks for the update!!
I’m not sure as to why it wasn’t working yesterday, let us know if it happens again.