fill and update data for 2 tables

Hello, I have two tables. CLIENTS with the columns Name (mandatory) and Phone (optional), and ORDER with the columns Date (mandatory), Name (mandatory), Phone (optional) and Text (optional). When I add a new client, I enter the name, and the phone is optional.

I need that when placing an order, it references the client’s name and automatically fills in the phone number. However, if the phone is not associated, it should allow me to add the phone at that moment, and it should be updated in the client’s record after submitting the order.

Thanks

Hi @JoaquimReis

  1. in your table ORDER, set a column with type Ref, source table CLIENT

  1. in your table ORDER, column phone: use a deref expression in the initial value field:
[CLIENT].[Phone]

For reference:

Dereference expressions - AppSheet Help

You may want to use an action “on form save” for this:

This will require you to create a specific action for updating another record, you may want what you need with a quick search on the AppSheet Community :slightly_smiling_face:

For reference:

Run actions based on view events - AppSheet Help

2 Likes

Hi @Aurelien , thanks for support.

Step 1 and step 2 Done

But the step 3 … save the data on form (table Order it’s Ok) but on table CLIENTS the phone it’s not updated.

Step3:

  1. in Action pane, create an action attached to table CLIENTS.

Let’s name it “update phone”, and pick the option “data: set the values of some columns in this row” and use this expression:

LOOKUP(
  MAX([Related ORDERs][_ROWNUMBER]),
  "ORDER",
  "_ROWNUMBER",
  "Phone"
)

For reference:

FAQ: FILTER(), LOOKUP(), MAXROW(), MINROW(), REF_R… - Google Cloud Community

  1. in Action pane, create an action attached to table ORDER

Let’s name it “call update phone”, and:

  • pick the option “data: execute an action on a set of rows”

  • referenced table : CLIENT

  • Referenced rows:

LIST([client])
  • reference action: update_phone

This one is the one that should be picked under the form view settings:

It should work :slightly_smiling_face:

For reference:

Actions: The Essentials - AppSheet Help

2 Likes

Perfect :ok_hand:

Thanks!

1 Like

You are welcome :slightly_smiling_face:

1 Like