I’m struggling with disabling options in a single select dropdown element. I’ve tried several variations on the disable condition, but it either allows all items or disables all items–I can not get the condition to only apply to the constraints of the formula. Images below.
Setup is slightly opaque, but:
Select box has a list of ‘boats’: “label per item” is the boat name and the “value per item” is the boat.id
A second table holds ‘schedules’, which are not directly referenced here
There is a third table, used as a join table to link 'boat.id’s to 'schedule.id’s. This table contains an ‘is_archived’ boolean so each pairing can be switched on and off at will. This join table is the boat_schedules table/collection in the screenshot.
At the end of the day, what I would like to have is the single select element only allow selection of a boat that does not already have an active (i.e., is_archived = false) link to the schedule.id (the “Item.data.id” in the formula) in the boat_schedules table/collection.
Note: it is possible that either the pairing of boat.id and schedule.id in the boat_schedules table already exists and ‘is_archived’ is true or false…or that the pairing does not exist at all yet.
Here is what I have that just disabled all items, regardless of is_archived status OR also in cases where the pairing does not exist at all.
Any tips or suggestions welcome. I’ve tried weweb (and external) AI a couple times to no avail. I’ve tried wrapping logic in a ‘contains’ statement as well to get a boolean result, but that did not seem to work either.
The disabled condition per item is expecting a true/false statement.
For your usecase, i think it would be better that your options had more information in each object.
To do this, you want to construct the array when you set options (or before, whichever works for you)
Thank for your response and suggestion. Its good to know the condition must be a boolean. This is what I suspected, but even when I was trying that it would not resolve correctly.
I went back to wrapping the original formula in a ‘contains’ statement and, after testing just now, I think this might actually be a bug. I discovered that if I hardcode the schedule.id into the formula, everything works as expected.
But if I use “item.data.id” for the schedule.id instead, it does not work as expected.
This select element is nested inside a list container of all the “schedule” items…so the “Item.data.id” here should (I think) refer to the “schedule.id” of the parent. However, it seems it may actually be returning the schedule.id of all the parent list items.
I think this is the case because, when the formula contains “Item.data.id” only 3 items in the select box are disabled: items with boat.id values of 4, 5, & 6 (which are, coincidentally, the schedule.id values of the 3 schedules in the parent list container).
If I hardcode a schedule.id value in place of “Item.data.id”, the proper items are disabled.
As a workaround, I created a new variable to hold a schedule.id value, then setup a workflow ‘on click’ of the select box that changes the value of this variable to be the parent schedule.id’s value. I swapped that variable in for the “Item.data.id” in the above screenshot and now the select box items are being disabled properly.
Great that you got it working! Not sure I understand exactly how your data looks, but it doesn’t matter.
I think i would still propose to have the data object constructed at an earlier stage for readability (and simplicity). But if it works, it works!