Hello! What is the best way to copy/duplicate a tulip table record and create a new record with a new ID? For example, I have the table record (ID=1, Animal=Dog, Count=5), and I want to duplicate, and create the record (ID=2, Animal=Dog, Count=5).
There are probably multiple ways to do this, but the one that sticks out to me is to use 2 record placeholders.
You load the record you’d like to copy into the first, and then use that reference record to DATAMANIPULATION → STORE the field you’d like into a new record. Here’s a video that shows you how I’d do it.
Let me know if this helps!
note: this a demo table I use in the API University course. I picked it because it was small so no significance there.
Hi @John , is there a way to duplicate all the fields in a record.
(My record holds over 50 fields, I guess I need at least 30 of them)
Do I need to use Data Manipulation and store each wanted field?
Is there a feature that simply duplicate all fields?
Here is a version similar to your suggestion were I store two of the needed fields.
There are a few different ways to go about this - there isnt a great way with the trigger editor to copy all/most of record A to record B without assigning each field individually - like you said. But, there are a few other aveneues you could go down. Are you looking to do a bulk move of data one time? or are you just looking to have your app write to both tables going forward?
IF A ONE TIME BULK MOVE-
If you are just trying to move a larget chunk of data to a new table, you could export a csv of table a, then import that csv on table b. This document outlines exporting data and this document outlines importing that data in a new table.
If you have some familiartiy with basic code, you could use the Tulip API to pull the data from table A and move it to table B.
IF YOU WANT TO WRITE TO BOTH TABLES GOING FORWARD-
Right now you are stuck with doing a data manipulation for each field into each table. There is currently a feature request in the works to enable you to create and write to all the fields in a record in 1 step (as opposed to 30-50) in your case. I will update this thread as that feature works it way through the developent process.
If you do have a software background - You can make a Tulip Connector function to create a record (guide here) with a single step. I have seen this approach used in the past to write 120+ fields in a single step, but its a bit of a pain to manage if either table has fields added. If you are interested in going down this road let me know and I can provide a more detailed explanation.
I just did the work adding the needed fields. Works fine.
By the way, the record is duplicated within the same table.
This is needed due to current report setup in MS Report Builder which I use to print packing lists.
I’d like to see this functionality too, cause I have to solve a similar problem:
I’m using a serial number also as ID and the employees will have the ability to change the serial number (because of mistyping or other reasons). The records holds ~60 values , so a more smooth way is helpful.
I added your comment to the feature request. You are hitting on something kinda key to Tulip, thats tricky to get right (until you learn from your mistakes) and that is data architecture.
Whenever possible I do what I can to not make the ID something that will ever be changed, and I usually do this by just making it a random string. Instead of having my ID as the serial number, I will add a serial number field and make the id field a random string (I usually use randstring() in the expression editor to create this).
When displaying data to the floor in your app, you can filter/sort based on this new serial number field, so their experience doesn’t really change, but now they can edit any field that might matter to them.
Unfortunately it is a little tricky to retroactively change the data architecture, especially if that table is large, or already live in production. In the past I have used the Tulip API to pull all of the current records, then make the change to the architecture, then push the data back into my table. I have done this with tables with 8+ million records with ~50 lines of code. Let me know if you want a little more information on how you could do something similar.
Hi Pete, thanks for your comments here. I’m trying to fix the ID of an entry in my table, and using the API to copy down the existing record, update the ID, and put it back into the table. After removing hidden fields from the record (updatedAt, etc), I’m running into some internal server errors when I try to do this, and wondering if there are limitations on the data types that are accepted by the API. Specifically, I have images and linked records that I would like to preserve. Thanks!