Hello there, I tried to recreate your issue and solve it. So you have configured the basic list component right, it refreshes as supposed to do etc. But You want to check wether an ingredient is in the list already?
For this you have to have a data variable that is the collection of the ingredients. When you have it, you can use this variable as a “list”. You want to check if the input’s value that is in your case also bind to a data variable. You want to do this check after clicking the button. I may have used different names, but you can adjust it to your needs. (also I never use capital letters in properties because I am never sure how they are interpreted so let’s stick to the following now).
So here is the data resource setup:
Next data variables:
Logic flow of the button tap event:
Here in the IF condition we set the value to the following formula:
IF(IS_IN_ARRAY_BY_KEY(data.ingredients_list, "name", data.new_ingredient.name),true,false)
This checks wether an ingredient has already been added. If true, it will show an alert with the following text:
`data.new_ingredient.name+" has already been added to the list of ingredients!"`
The rest is self-explanatory.
But only if your user will be careful enough not to type e.g. “sugar” and “Sugar” since these are different in the capital “S”. Because the two will be regarded as a different value. So the next part is optional but a good to know paragraph:
If you want to avoid lowercase and uppercase issues I suggest changing up the Create record flow function to the following:
Where the right formula is the following:
LOWERCASE(LOOKUP(source.object, "name"))
This will store the lowercase version of the new_ingredient.name property which is more sure to provide the best check at the IF
formula. Also to double check yourself or the user you could change the IF
formula to the following as well:
IF(IS_IN_ARRAY_BY_KEY(data.ingredients_list, "name", LOWERCASE(data.new_ingredient.name)),true,false)
So that now it is really sure that there will be no duplicate ingredients in the list.
*Last side-note: I would use a simple container with repeated data of data.ingredients_list
for best design and layout options. Thus you have more flexibility then in the basic list
component. But that is I guess still to come in Your journey on this platform. Hope you will find it useful as well.
Best wishes