Action to copy a field into another table with a single record.

I have a table “Week” with a field called “NumWeek”.
When I am in a record of that table, I want to copy the value of “NumWeek” to another table called “Config” in the field “WeekConfig” when I press a button.
What would be the best way to do it?

The action “Data: execute an action on a set of row” by putting Reference Table : Config asks me for Reference rows which in my case is simple: LIST(“1”) since I only have one record.
Then it asks me for Reference Action and I have defined “TablaQueSem” in the table “Config”. From there I cannot mention the value of Week.[NumWeek] and I have no choice but to put an INPUT.

I have tried to use “Data : add a new row to another table...” putting the ID of “1” and it creates a record with that data but it empties the rest of the fields.

Does anyone know a better way?

You may want to add if

  1. The two tables have reference relationship

  2. When you execute an action every time, will the [ Weekconfig] in “Config” table be updated by the [NumWeek] value from the record of the Week table. This Week table record is the record from where the action is initiated.

  1. No, there is no relationship between the tables.
  2. Yes. Config.[Weekconfig] is updated with the value of Week.[NumWeek] every time the action button is pressed on a Week record.

Thank you. Maybe someone has better solution with this configuration and I am missing some obvious point in my solution.

I have tested it with a bit longer configuration with 3 group actions and requiring addition of a column in the Week table. I can share it if you wish. Please let me know.

I would be very grateful if you could share it.
Best regards.

Please take a look at the following approach. Maybe there are better approaches but this one works.

  1. Add an Email type physical column called [CONFIG_Email] in the Week table. You can hide this column.

  2. . Add the following action in the Week table

Set this action to 'Hide" position

  1. Add the following action in the Week table

Position of action: Hide

  1. Add the following action in the Week table

  1. Add the following action in the Config table

Position of action “Hide”

Expression to set the [WeekConfig] column in the action

ANY(SELECT(Week[WeekNum],[CONFIG_Email]=USEREMAIL()))

  1. Add a group action in the Week table as follows

Position: As you want Prominent or Inline or Primary

When this action is invoked from the Week table by the user , the [WeekConfig] will change in the Config table

Please test well for your requirement.

Great!. It works.
Thanks a lot. I was stuck.

Maybe AppSheet should consider the action
Data: set the values ​​of some columns in other table
allowing to indicate “For a record if this table”, “Reference Table” and instead of “Reference Action” put “Set these columns” as in the action “Data: set the values ​​of some columns…”.

I think it is something very common and would be simpler than the method you propose (although this one works for me because it works). :+1:t2:

You are welcome. Thank you for the update. Good to know it works.

I think some referencing between the two tables will help in reference actions.

In this particular case since there is only one row to be updated from many rows it was a bit challenge even for referencing which we solved by using USEREMAIL() based approach.

I still feel we may have an easier approach. If I can get one, I will post.

Based on the information you provided, I have changed it slightly.

I use a text field in the source table that I call Marker.

In the first action I give Marker the value of Yes.
In the second action I change the expression to:
ANY(SELECT(Week[WeekNum], [Marker]=“Yes”))
In the third action, I give Marker the value of “”.

Okay. However I believe in multiuser environment, USEREMAIL() will work better.

If two or more users try to update the Config table simultaneously, there will be two or more rows with " Marker" filled and result will be unpredictable.

You are right. What you propose is more reliable.
In my case, this process is executed by a single user.

1 Like