Add data to a multiselect or array cell without overwriting

Hi there,
I am moving my first steps with Make and I got stuck.

I need to add a productID passed by my webhook to a specific baserow cell. The thing is that the cell already have some data and I wonder how to add other data. The cell is part of a column of multi-select type. But I can also make it an array type (by referencing a table from within that baserow table I am working on).

I tried both ways and Make correctly sees the multi-select items and the array items.

The situation is that suppose I have 3 productsIDs in total. A customer data is present in a row of that table, with name, email, etc and productID bought. So he can have 1 productID, or 2 within that cell.

Suppose that same customer buys another productID. I need Make to add that productID in the cell containing other productIDs, be it empty or not. While adding, Make must retain the other productIDs present there (if any).

How to do that? Do I just need to use the map toggle and insert the variable there? Or will it overwrite everything present in that specific cell?

Edit: I now found that there are operators and array adding, maybe that will work? Don’t know how to use it.

1 Like

Yeah inserting the new value directly will override the existing value. So you need to get the existing value first, add the new value to it and place the resulting combination in the cell you are looking to update.

Does the existing value come in as an array or a comma separated list?

1 Like

It can come in either way, this is something I am having trouble deciding. In my baserow table I am not sure which column type assign to this. Depending of this type it will be an array or something else. Multiselect, reference another table, other?

I would like that Make adds a value in that column without me needing to manually update the multi-select options when a new productID is being bought which is not present in the multi-select options.

Hence I believe referencing another table within that column can be a good idea. That second table will just contain the productIDs and if a new one is added, Make should be able to add one there? I am not sure of that, because in Make when I visit that field, it presents me with +Add item for each row, but there no “add row” there

1 Like

I checked, the existing value is an array

1 Like

You can use add() to include the new value in the array and then post the resulting array. This way it should retain the existing data and add the new value to it instead of erasing everything and only having the new value.

1 Like

I am having trouble writing the correct function. I would like to ask you if you know how to. I will explain.

I have a specific collection containing text which interests me, it is here:

It is “Event Summary” which contains “Event ID” and “Name”.

I want to add those 2 to an array made like this:

The array is called “IDeventi” and has collections named 1 , 2 , 3 , etc.

I want to add a new collection to this array. So if it has none, it will be named 1. If it has 3, it will named 4 and so on.

Inside this new collection I want to add the values “Event ID” and “Name”. I see it seems like I can’t add the “Name” because I only get ID value and order hence I will map my “Event ID” to “value” (other fields are automatically created by baserow) and forget about “Name”…

The goal is to add this without overwriting the other collections.

How to construct the add funcion?

1 Like

Here

2 Likes

Just to point out that in my case the issue was not exactly what has been discussed. In my case I needed to link a baserow table to another table. And this is how you do that. It works but is imperfect because I do not know how to update a row without overwriting, but this is more a Baserow thing I suppose.

1 Like