Hi all.
I’m trying to create a system of articles, but I can’t implement it.
I need the last (highest) article to be taken when product creating . Also, it would be increased by 1.
As a result, I need to create the new product wich have a unique article that is not repeated with anything from the list.
I tried to implement my idea like this.
In “New Column” I count the number of “Row ID”. Next, I add 1 to “New Column A”. And with the action I put from “New Column A” to “PreArticle”
Take a look at this: How do I create an auto-incrementing row number with Glide Tables?
I already looked at this, but in the first method I was faced with the impossibility of using two different tables. The second one doesn’t suit me because it counts the number of lines and outputs a number based on the number. And when you remove any of the goods, the number decreases
What I need is to take the last number and add 1 to it, and then put it in “PreArticle”
That needs to be part of your action flow. Take the last number of the last row, add 1 to it, and use a Set Column action to write the calculated number permanently to the PreArtical column.
What do you mean by this? Can you explain further?
I meant that when creating an action, it is not possible to change values in two different tables in one action
You should be able to write to one table with the Set Column action, and then pull that value to another table with a Single Value or Relation column.
Yeah, I’m not sure why you would want to write the same value to two different tables. As @nathanaelb said, you can retrieve the first, last, or any other values into another table with a single value column.
I need to achieve this result:
The number of products will periodically change up or down, I have a separate table in which the number should be stored. The cell should be simple. When the manager adds a new product, the first action must take the number from the cell, increase it, insert it into the table with the products, and then write the increased number back into the storage cell. The number should not decrease
You don’t need a storage cell unless you expect the last row to be deleted at any time before the next product is added. If that would never happen, then a single value column can retrieve the max PreArtical value when you need it, and a math column can add 1 to that number.
If the last entered product could be deleted, then the single value method won’t work because it would reassign a number that existed on the previously deleted item. In that case, yes you need to store the most recently assigned number somewhere. I think that would require a bit more knowledge of your data and app layout but generally I would suggest a separate table with a single row just to store this ID number. Then in the appropriate table, add a ‘Single Value’ → ‘Whole Row’ column that links to that new table. This will allow you to set column values through that single value, which works just like a single relation.
I just want to add that creating sequencial numbers in Glide is not ideal. At most it’s a hack. Operations are not atomic, so 2 users adding products at the exact same time can and will lead to duplicate numbers no matter what. These calculations to retrieve and add one to a number happen on the end user’s device, so by the time data syncs to the server and back to all other end user devices, you might run into conflicts where the same number was assigned to two different products. If products are being added by one user on one device, then you shouldn’t have a problem, but this is something to be mindful of if multiple people are adding products at the same time. In that case you need to involve an external service that can run atomic operations and process data sequentially to assign numbers.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.