Hi community,
I need to insert all the content from one table into another in bulk, both have similar columns.
Any recommendations? If I could do it without Make, even better. But I can’t find any other way…
Hi community,
I need to insert all the content from one table into another in bulk, both have similar columns.
Any recommendations? If I could do it without Make, even better. But I can’t find any other way…
Do you need to do it multiple times? If not, I would just copy and paste them over (have to organize the columns in the same order first though).
If it’s too much to copy/paste, you can use CSV export/import.
I need to do it without interference from the administrator or the programmer, which means it should be done with a click from the end user within the app. Therefore, importing/exporting .CSV files (unless it can be automated) or manually copying/pasting the table won’t work for me.
If you have a Business Plan or better you can use Call API. Otherwise you need to use something like Make or Zapier.
But I’m curious, what is your actual use case here?
Why do you need to duplicate the entire contents of a table? Seems odd.
Could you explain me the Call API method ?
I would imagine it being something like:
Constructing an API body for every row of the old table that fits the “add row” structure. You can use one of the JSON columns to help with this.
Combine them all into a batch and use the Call API action to bring data to the new table. If you have a lot of rows, maybe separating them into smaller batches would be better.
If you use a Google Sheet I have a script for you … Darren actually wrote it for me so you know it’s good !
Thanks but Im working with Native tables
How can I construct a batch?
You can check out the mutations part here. The mutations array can contain multiple mutations, in your case multiple add rows.
Construct the add row JSON on each row, then use a lookup to join them together and reference that in the final JSON for the API call. I believe it will construct the array automatically for you.
Hi ThinhDinh this is the situation:
I managed to create a template for the RequestBody.
I reference that template in a column of type IF to avoid empty structures (from the unused rows)
Then, from another table, using a lookup column, I retrieve the request body for all rows (the ones with info, not the empty ones).
BUT when making the API call, I cannot reference that lookup in the property of the Call API command…
I know I’m just missing a step, but I’ve been struggling with this for a while. Could you point out any corrections?
You’re trying to pass an array into something that only accepts a single value. You’d probably need a Joined List instead to convert the whole thing into a single text string, but I’m pretty sure there is more to it than that because the entire group of individual mutations will need to be wrapped with brackets. You’re also probably better off using the JSON Object column for some or all of it. I haven’t had a need to dive deep into that world, so I’ll let the others chime in with specifics. Just wanted to give you a head start with an explanation of why you aren’t able to select your lookup array.
Along with @Darren_Murphy, I’m also curious about the reasoning for duplicating all of this data. Usually when data is duplicated, it means someone is trying to solve a problem with the wrong method. In most cases, data should never need to be duplicated. Not saying that’s the case here, but we hate to give the wrong advice if there is a better way that fits with your use case.
The first thing I did was create a JSON Object that I later referenced in the other table using a lookup column, the issue was that the request body field of the Call API action also did not accept that JSON Object. That’s why I decided to make it a template so I could reference it, but I couldn’t reference the request body in either of the two ways.
Regarding why I want to insert the same information from one table to another… I hadn’t mentioned it because it’s a long explanation, but here it goes:
I have a previously created functionality where the user uploads an image and extracts data through AI, inserting it into columns. That functionality works perfectly, but the user has asked me to do the same thing but in bulk, uploading up to 50 images at a time (without discarding the previously made upload of 1 by 1). I have solved the bulk upload and data extraction, but the problem is that ALL the data extracted from the images (whether one by one or in bulk) must be visible within a single table called OPS (which is the one the user consults). However, for the bulk upload and extraction process (the 50 images), I use other tables that have nothing to do with OPS. So, once the multiple images with their data have been processed, I want to copy and insert all of that into the original OPS table and then delete everything from the bulk upload tables… in other words, the bulk upload and extraction tables would only be for assistance (helper tables) and would be periodically deleted.
All this problem is due to the lack of a simple Loop command or the ability to iterate through a list that would allow us to perform actions on a list of records. So, the only possibility I have found to make a bulk insertion from one table to another within Glide is through the API, passing a JSON with all the rows from the bulk upload and extraction table to the OPS table.
I think you’re indeed missing a step here. In your JSON that you have so far, you’re only specifying the column values, is that correct?
You would have to add a JSON Object column to get the appID in, and the mutations would point to the lookup you have.
That makes sense. Thanks for the clarification. We’ve seen people in the forum try to do things that unnecessarily complicates their app, so it’s nice to understand the use case so we can give the best advice.
Those column references don’t look right.
When referencing columns via the API, you need to use the 5 character native column names that Glide assigns, not the names that you assign yourself.
Ok I will add that but still can’t reference the request body column which is a lookup from a template…
the mutation should be this JSON?
The template column is the request body, the info that I want to insert into OPS table…
First you should check the Show API > cURL > Add rows template in your data view to see if the column names are matching. As Darren stated, it usually is the column ID, instead of the names.
Regarding the mutation, it should be all of the things in the data-raw part.
You are having just the columnValues part.