Copy data in multiple tables

Hi,

I have 2 tables:

  • Item
    • Item 1
    • Item 1
  • ItemMeasure
    • Item 1 – Measure a
    • Item 1 – Measure b
    • Item 1 – Measure c
    • Item 2 – Measure a

Is there an easy way to copy the data of item x to another 2 tables? I found a solution with triggering the second table with the first table. But isn’t there a better, cleaner solution?

  • backup_Item
  • backup_ItemMeasure

Thanks
Andreas

I’m afraid I’m not following with what you require. Can you elaborate?

Hi, off course.

My sample data in the 2 source tables:
table Item
|Item ID|Item Description|
|Item 1|my Item 1|
|Item 2|my Item 2|

table ItemMeasure
|Item ID|Item Measure|Value|
|Item 1|Measure 1|1 500|
|Item 1|Measure 2|2 000|
|Item 1|Measure 3|2 500|
|Item 1|Measure 4|3 000|
|Item 2|Measure 1|15 000|

The [Item ID] is the primary key.
With one action (copy Item) I want to copy one selected item from both source tables into the backup tables.

with SQL I would to the following:
insert into backup_Item select * from Item where [Item ID] = ‘Item 1’
insert into backup_ItemMeasure select * from ItemMeasure where [Item ID] = ‘Item 1’

The result should be:
table backup_Item
|Item ID|Item Description|
|Item 1|my Item 1|

table backup_ItemMeasure
|Item ID|Item Measure|Value|
|Item 1|Measure 1|1 500|
|Item 1|Measure 2|2 000|
|Item 1|Measure 3|2 500|
|Item 1|Measure 4|3 000|

Thanks

@andima
3 simple steps:

  • Create an action with below behaviour
  • Set prominence to Do not display
  • Assign the action to the Event Actions > Form Saved behavior of the Form UX of the Table

Repeat this process for both tables.
This will provide that when a new record is created in both tables, same row data will be copied to the targeted table.

1 Like

Thanks!

This is working fine if I create new data.

But what I want to achieve is, to copy the data from both source tables to the target tables, if I update the data in the table Item.

If I update table Item, the data of the updated Item in the table Item and ItemMeasure should be copied to the tables backup_Item and backup_ItemMeasure.

Unfortunately I don’t follow you :thinking: :thinking:

Hi, I just found a solution:

Not really straight forward - but it seems to work.
Is there an API to implement more complex behaviour like this?