Update a parent value from a child table

Hi every one, i need somme help for m'y problème After days of research, i have tow parent child tables workers AND attandance ,  in each Attendance I have extra hour values that I want to store in workers table , how can I do that

Thank you

0 2 35
2 REPLIES 2

Hi, maybe you can do a Virtual Column in the parent table with a formula like this:
Sum(select(childtable[extra_hours],[Employee]=[_ThisRow].[Employee]))

You said that both workers table and attendance table are child tables?
What is the parent?  

I am assuming that the structure is like this

Parent Table
- Workers Table
- Attendance Table

So that means, that both Child tables have a Ref column pointing to the Parent table's key column.  Something like

Parent Table
[Parent ID] -> UNIQUEID()
[Related Workers] -> REF_ROWS("Workers", [Parent ID]=[_THISROW].[Parent ID])
[Related Attendances] -> REF_ROWS("Attendance", [Parent ID]=[_THISROW].[Parent ID])

Worker Table
[Worker ID] -> UNIQUEID()
[Parent ID] -> REF to Parent Table
[Extra Hours]

Attendance Table
[Atteandance ID] -> UNIQUEID()
[Parent ID] -> REF to Parent Table
[Extra Hours]

Imagine the data flow.   From the limited info you provided, I am assuming that you have no column in Attendance table that is related to a column in Workers table.  I am just guessing.

If this is the case, then from the Attendance table, it has to traverse back to the parent table, then go down to the Workers table.  (Attendance -> Parent -> Worker)

The question now is How will Appsheet know which Worker row it needs to find in the worker table, based on the given record in Attendance Table?

Therefore, it needs to have some sort of matching rows or values.  I would assume that Attendance table should have information about the worker, right?

Therefore, the tables, should actually be like

Parent Table
[Parent ID] -> UNIQUEID()
[Related Workers] -> REF_ROWS("Workers", [Parent ID]=[_THISROW].[Parent ID])
[Related Attendances] -> REF_ROWS("Attendance", [Parent ID]=[_THISROW].[Parent ID])

Worker Table
[Worker ID] -> UNIQUEID()
[Parent ID] -> REF to Parent Table
[Extra Hours]

Attendance Table
[Atteandance ID] -> UNIQUEID()
[Parent ID] -> REF to Parent Table
[Worker ID] -> -REF to Worker Table or Text+Valid If or Enum-Ref+Valid If
[Extra Hours]

If my assumption is true, then you can save the Attendance [Extra Hours] by looking up the Worker in the Worker Table using the [Worker ID].

You can then use this in a customer action for Attendance Table, to Add new records to another table using values from this row, pointing to the Wokers table.

Then in the action setup, you just have to point
Extra Hours = [Extra Hours]

You can then have this action hidden and set it as the "On Form Save" settings of your Attendance Form.

Top Labels in this Space