Currently, I have 3 tables which are “products” table, “needs” table and “need_product” table on Supabase.
The relationship between 3 tables is one “product” can have many “need” items and one “need” can have many “product” items which means, “need_product” table is many to many table for “product” and “need” tables that requires to have “need_id” and “product_id” as columns.
I’m able to dynamically add and delete on “need_product” table by inserting / deleting need_id and product_id by using Data-grid.
Here, my question is how to edit them dynamically.
How to dynamically show dropdown options that are not part of default values.
For example, I only want to see “Instant Marginal Analysis” from the dropdown option instead of
what is shown on the screen shot below.
How to get selected or disSelected need’s id to delete or insert on Supabase when the Save
button is clicked?
I don’t know where to find those data to bind properly.
I don’t understand your first question, but for the second, you gotta make a function i think with copilot, that checks your selected items array and your previous, and points out those who were removed/added. Then based on that with a workflow delete the things that result to be removed
To check if arr2 contains the value of arr1 I use the following function
And use it like this, or like a nocode formula. The in_key and from_key are there for the case where you have a specific value you want to filter by in each record. Otherwise set them to ""
Now, I got the flow to work on this but wonder where to find the selected items array.
I made the helper function just like you showed me and tried to use the function on Multi-option split.
To pass the right parameters, I guess I need to find the selected items array and the previous.
Where can I find the selected items array?
Seems like “Datagrid-selectedRows” are empty and “Event” on Row Update only has the original values.
(I also added an item on UI to make sure to update values before working on the workflow.
Only have add option because I wanted to focus on add first before covering all the options.)
You actually need to add your arrays as parameters, in the formulas[...](here), that’s why you’re getting the error.
As for the selected array, what are you using as a select? If you’re using multiselect option from WeWeb, you should be able to see, multiselect values. But I think that you might need to use this guide from Mariano
to get the values in the selected array. Could you tell me more about your logic?
@Broberto Let me show you the grid data first.
Since I’m fetching this data that has many to many relationship, I made a function “transformNeedProducts” that returns Object.values(result);
Then, I used the function to display Grid data on DataGrid.
It’s an array of objects that has an object of product and array of needs objects that has name and id of it.
I’m using “product.id” as a unique id because I’m not sure what else I can use
but I’m assuming that this might cause an issue because it’s not technically an id of the object. I guess it’s one of my question, what would be the right unique id for this case?
I’m using multiselect option but I don’t see multiselect values. Where can i find them? I remember when I use select option for different cases, it was a lot easier to find the changed values but I don’t know about the multiselect option. Do i need to do extra step to get selected arrays for multiselect option?
I also created a variable to follow the guide from Mariano and saw there’s an item I’m supposed to bind to but again, I don’t see it on my screen. Where am I supposed to bind for path and value?
Unique id is anything that is guaranteed to be unique and each item has it, for example your uuid, if it’s unique for each item in your transformed array, then it should be all good.
You might want to look into the “From this Project” and look if it’s not in some folder. Or check if you really created it. I’m not sure I can help you find it like this