When you say create a column only if it does not exist, do you mean if the column’s title doesn’t exist? Or if there are no columns of that type in the board?
Let’s say we want to add an item with a field “XYZ” to a board ABC.
We are not sure the board has the column XYZ. If we create the item and the column is not there… that field will be ignored.
To be sure we need to 1) read columns in the board. 2) if the column is missing create it
Then we can create the item safely
The problem we see is that if we want to paralellize this, and create multiple items in parallel, there is a chance that we read and create multiple columns with the same name but different internal IDs.
Ideally, I would like to have a way to “create column_id=QWERTY” so we are sure of the id and we don’t need to check if the column exist. Creating column by “name” and not “id” is very risky
Maybe there is something wrong that we are doing and there is already something in the API for this use case?
Well… this is exactly the race condition I am talking about…
If it does not exist, you can create it:
if we have parallel API calls (event/webhook base) then may create the column twice with different identifiers. Also people can rename columns and break things…
If users change the column name, the columnId will stay the same. I do not see a reason why this should break an app as I assume you are using columnId’s.
What matias suggested was to verify that the column exist by searching the column name… and if it is not there… then create…
if the column is renamed, you cannot rely on the check.
We don’t want to track column_id separatedly in a different DB… that would be complicated and error prone.
Understood, you can never rely on a column name as the user can always change it. The best solutions depends on a lot of things, like:
do you create the column through the API? In that case I suggest to create a column through the API with a unique name (timestamp?). The columnId will now be the same as the column name (timestamp) and you can rename it to whatever you want.
if the board (e.g. derived from a template) already contains the column you can check the columnId because boards derived from a template has the same columnIds as in the template
Without knowing the exact flow I am afraid I can’t help further.
Just to let you know that searching for the column name fails sometimes. We are still investigating the problem with @Matias.Monday but it seems related to column permission or column now available thru API just after their creation.
Yes, we could eventually do something like that… create with a random unique name and then track the column_id in a separate DB. But it is not ideal…
My concern is that once you start adding too many workaround due to API limitations… code looks strange and affects long term maintainance… but ok, it is possible to encapsulate all these things and wait until the API gets better
Yes. As I mentioned, you could query for the titles of the columns. I mentioned this since I asked before, and you replied saying that you wanted to use the titles (like “XYZ”). I also mentioned the IDs as well, so that you knew that you could use them too. I gave the example of the column creation of a column with title “Text Column” with the ID text_column which is related to what was said about the “custom IDs” set by creating the column via API. Obviously as it is mentioned, using the IDs is better since those are unique.