Using js to copy data from tableA to tableB

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I'm using the CSV import from Dropbox to populate a table, and I need to move that data into another table in the same app, multiple times a day, in an automated process... Woulda been nice to be able to import it directly into the already-existing table that I need the data in, but that doesn't seem to be available.....

**Please tell me if there is an easier way to do this**,
but the method I came up with, was to use the image OnLoad technique, and put the img on a dashboard page that users access, regularly. Of course, this isn't a precisely timed interval, but QB doesn't have any timer/cron functionality (hint!). I created a saved export template, and am hoping to have the .js, called by the OnLoad, execute the saved export template ... but I dunno how.

Also, since I am new to QB, feel free to point out any issues with my approach..

Photo of Derick

Derick

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
You would need to create a new table to do this, but you can set up QuickBase Sync to Copy data automatically from one table to another each hour, plus on request
Photo of Derick

Derick

  • 0 Points
OK, how can I use Sync to copy from one table to another? I thought it only was to bring in external data? Though, my need is to bring in the data into an *already-existing* table.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
QuickBase Sync can use another QuickBase table as its source.  But at present, you cannot retrofit an existing table to be Sync'd. I understand though that ability is somewhere on their future development list though.
Photo of Derick

Derick

  • 0 Points
Ya, the "existing table" restriction is the problem, which is why I went with the onLoad -> .js -> import template route.
But what would I put in the .js to execute the import template?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
The method that you are describing I call the "Dashboard Cron". Although you don't get precise control over the time that script executes your users will pass through the dashboard repeatedly and potentially invoke the script a large number of dimes during the day. You will actually have to rate limit the running of the script so it does not fully execute (and move the data) to some type of balance point between how often your users pass through the dashboard.

FWIW, you can also apply the same technique with Service Workers. where you can potentially trap every fetch request and conditionally run the table move portion of the script if it hasn't been run recently enough. For discussion purposes let's call this a "Service Worker Cron".
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
The API called API_RunImport&ID=10 will run import #10. But I don't know JavaScript for how to call it.
Photo of Derick

Derick

  • 0 Points
I found this code here: https://www.quickbase.com/db/bcdcajmrg?a=dr&r=dq&rl=g3h
but how can I execute it in Quickbase ... it doesn't look like .js code.