Button Problem: Automatic Name Generator

The goal of this doc is to use a button that adds a row in the table RunNameGen which, as the name implies, creates a standard new name (RunGen), based on the current date. At the same time, the button adds a row to a production history table (Runs), in which the production ID (Run ID) is taken from the RunNameGen table.

Notice that button 1 fails to select the last item from the list of RunGen. Instead, it appears to replace the last item of the list by a term “1masc”. This can be confirmed by using button 2, which puts the whole list of RunGen as the RunID.

I appreciate if anyone could tell me what is wrong with the code?

Hey I’ve requested access to the doc to have a look into it :slight_smile:

1 Like

Hey @Alexandre_Nascimento
from what I can see, there is nothing wrong with the code.

I think it has something to do with the order, operations are processed, when two actions are executed at once.

So when you run the actions it probably follows that order:

  • at first, the new row is generated in “RunNameGen”, but the fomulas in the columns are not executed yet
  • then the Row in Runs is created, taking info from the not yet finished last row
  • then the formulas in the new last row are calculated

This leaves your concatenate formula with 3 empty date fields and 1 in rank added to ‘masc’.

This behaviour was changed at least 1 or 2 times already, I will check with other champions if there are workarounds to make that happen. I have tried 3 different ways now but always the same solution.

Fun fact:
In the embed version of the doc, where you have the “Play mode” enabled, IT WORKS :smiley: I have just tried it with a different version of your doc in another location, and it also works there, when the doc is embed…

1 Like

Thank you @Daniel_Stieber .

I’ve been suck with this for some time and its good to know that I this problem has happened before.
I will try some workarounds myself.

I did not quite get what you meant by the fun fact… kind of a noob here.

Thanks again!

Regading the fun fact :slight_smile: You have embedded the doc in your first post. When I press the button in that embedded version, it works for me:

1 Like

Perfect! That was the goal!

But this playmode for embedded docs is only temporarily visible for the user itself and only saved in his browser until page reload. So not usable in production when you want to keep the data.

I found a way that works, but it is a different approach and I’m not sure if it fits your overall project. Here I do all the calculations in the button itself, not in the column formulas:

1 Like

That’s great, really!

Thank you very much @Daniel_Stieber