Add same data in 2 Tables at same time

Hi,
Is it possible when I am posting to a table to set an action to post same data into another table at the same time? One is for regular usage the other one is for backup with some extra fields.

Thank you very much.

Absolutely, you would just have 2 Add Record functions in your Stack - one for each table you are adding the data to :slight_smile:

1 Like

Wow @michael this is pure gold. Thanks a lot, so many goodies in there.

Hi @michael ,
I was able to successfully apply the function, but is there a way to add the record to other table only when I update a field in the main table?

Example.

  • I create a record in Table 1.
  • I update a record in Table 1 with field change from 0 to 1
  • I add that record updated to the other table

Thank you very much.

Yes, you would go about it in the same fashion. And what you can do is use the variable name of the updated record to be added to your second table, for example:

And you can definitely get even more nuanced with things like Conditionals and other functions just depending on what you need to do.

Hi @michael,
Thanks, so in this case you didn’t use a custom function, you directly added the condition into the endpoint, I guess then custom function is if you want to add another layer of complexity correct but not mandatory?

I see you added only 2 fields to the input:
image

But while I update 5 fields, I need to pass the data from 12 fields to the “history”, should I just add them all to the POST endpoint and they will be “fetched” automatically? Or I need first to Add a custom function to the GET request to post those 7 fields to “history” and then the POST with another custom function to update the 5 fields?

Thank you very much :).

Custom functions are great to use if you wish to re-use the logic in different places or wish to hide the complexity to give your endpoint a “cleaner” look. It’s certainly not mandatory but is nice for organization.

Yes, I was just doing a simple example in the video.

So if you’re updating 5/12 fields to table 1 and want to pass all 12 fields to the “history” table you stil only need the single Edit Record function. The output of that function will have all 12 fields from that Record. As I show you in the video, you can use the variable name and either dot notation or the “get” filter in order to grab the specific field you want from the original record to pass it to the history table. For example “variable_name.field1”

Awesome, thank you very much @michael , will give it a go. Keep you posted.