Update a specific value in another table

Hi, I'm new on appsheet and I'm working on a shopping app to save all the products I have already  bought and those I would like to buy.

I have the first table named DA PRENDERE where I have a number for quantity and an action  ( ๐Ÿ‘AGGIUNGI ) to check the product .

Then I have a second table named PRESI where I have the list of all the product I've bought with some actions , date and a total number of products bought.

I would like, after clicking the action AGGIUNGI , to update the total number of  bought product.

So I have quantity 2 for milk in table DA PRENDERE and after click I want to change milk quantity in PRESI table.

03.png

 I tried to execute an action in another table.  Why in referenced row I can select only column? It's the right way? (I selected PRESI [PRODUCT] because the right one , QUANTITA, get an error about type of data). The action to call is UPDATE VALUE with 2 input, quantity and index (an ID created by myself) . [QUANTITA] and [ID PRENDERE] are columns or the specific value I clicked on, from these columns ?

 

04.png

 In UPDATE VALUE to select the right row I thought to use a behavior to check if the index of the product is the same saved in input .

Sorry for all my errors but I'm trying to understand this new logic of coding.

thanks

Solved Solved
0 2 187
1 ACCEPTED SOLUTION

Steve
Platinum 5
Platinum 5

@RAFFAELE_GOLD wrote:

In UPDATE VALUE to select the right row I thought to use a behavior to check if the index of the product is the same saved in input .


You claim you're new to the logic of coding, but I'm impressed with the approach you used. It isn't wrong but it could lead to complexity later as you continue to develop your app. Specifically, the expression here:

Steve_0-1729171560154.png

Should identify the one specific row you intend to update. A row is identified by its key column value. Your post doesn't make clear what the key column is of the PRESI table, but you did use ID PRESI elsewhere, so I'm going to guess that's it. If so, the Referenced Rows expression should be:

LIST([ID PRENDERE])

With this properly configured, the AGGIUNGI action will apply the UPDATE VALUE action to the one row of the PRESI table that has the key column value matching that of the ID PRENDERE column value from the row of the AGGIUNGI table.

With the above done, you don't appear to need the INDEX input:

Steve_1-1729172112967.png

Or the condition in the UPDATE VALUE action:

Steve_2-1729172407698.png

 

View solution in original post

2 REPLIES 2

Steve
Platinum 5
Platinum 5

@RAFFAELE_GOLD wrote:

In UPDATE VALUE to select the right row I thought to use a behavior to check if the index of the product is the same saved in input .


You claim you're new to the logic of coding, but I'm impressed with the approach you used. It isn't wrong but it could lead to complexity later as you continue to develop your app. Specifically, the expression here:

Steve_0-1729171560154.png

Should identify the one specific row you intend to update. A row is identified by its key column value. Your post doesn't make clear what the key column is of the PRESI table, but you did use ID PRESI elsewhere, so I'm going to guess that's it. If so, the Referenced Rows expression should be:

LIST([ID PRENDERE])

With this properly configured, the AGGIUNGI action will apply the UPDATE VALUE action to the one row of the PRESI table that has the key column value matching that of the ID PRENDERE column value from the row of the AGGIUNGI table.

With the above done, you don't appear to need the INDEX input:

Steve_1-1729172112967.png

Or the condition in the UPDATE VALUE action:

Steve_2-1729172407698.png

 

@Steve wrote:

You claim you're new to the logic of coding


Hi and thanks to reply. You caught me ๐Ÿคฃ I'm new to this logic of coding but I'm not new to coding . I like to play with AppInventor, kodular, thunkable and scratch , a very different approach . I usually work with variables and their interactions , here I don't know how and where to find what I need ๐Ÿ™ˆ 


@Steve wrote:

I'm impressed with the approach you used


Thank you so much , I really appreciate your words.


@Steve wrote:

it could lead to complexity later


 

I think so too . But it was the only way I found. I spent a lot of time  to get the index value and how to use it in UPDATE action (I have to change my way to work here)

So LIST([ID PRENDERE]) should give me the ID value of the clicked element ?I tought it was for creating lists ๐Ÿ˜…

Yes , I use a column ID filled with unique IDs, made by myself , different from RowNumber because I tought that RowNumber, for the same product, is different table by table (the order isn't the same )

I followed your advice and with LIST([ID PRENDERE]) works good , great. I can update  the quantity value in table PRESI according to PRENDERE quantity.

I used this expression  [_INPUT].[quantita] + [QUANTITA] in UPDATE action 

RAFFAELE_GOLD_0-1729198447455.png

I also delete INDEX input and the behavior, checked ID like key and delete a computed key appeared in the table 

I need to learn more about the basics of this platform to access its power 

Top Labels in this Space