Javascript SDK - Copy Parent and Child records to two new tables

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
So I have been working on this project relentlessly for a while now, and I feel that I am so close. I am creating checklists, and am using 4 tables to do so. I have the following tables

Checklist Task Templates
Checklist Templates
Checklists
Tasks

I have this set up so that the [Checklist Task Templates] feed into the [Checklist Templates] as child records.

The idea was to then have a button that would be clicked that could copy the parent and child records from the [Checklist Templates] table and put the corresponding data into the [Checklists] and [Tasks] Table. 

I got this setup from the All-Star Project + Task Templates in the Quick Base Exchange. This app did exactly what I was looking for, so I used the same logic and setup for the app I had started. However, this app uses the Javascript SDK. I made the attempt to set this up, but honestly can't figure out if I'm supposed to install the QuickBaseClient.js file somewhere, and if so where to do it. 

So after searching the community, it appears this may be an outdated method of performing this task. So I am seeking information on how to either implement the Javascript SDK method, or a more modern solution to my problem. 

Thanks!!
Photo of Andreonna

Andreonna

  • 1,040 Points 1k badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
That SDK is outdates yes, but you just need to reference it in you code and it still should work just fine.
Photo of Andreonna

Andreonna

  • 1,040 Points 1k badge 2x thumb
It is referenced in the code. So I must be missing some other changes in the code to get it to work in my app. 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,512 Points 20k badge 2x thumb
The github page for QuickBaseClient.js hasn't been updated for five years:

https://github.com/QuickbaseAdmirer/Quickbase-JavaScript-SDK/wiki

And it references JavaScript version 1.2 which had a release date of 1997 (20 years ago!)

<script language="JavaScript1.2" src="/js/QuickBaseClient.js"></script>

https://en.wikipedia.org/wiki/JavaScript#Version_history

This library is so woefully out of date that is from the stone age. Using it will only hinder you.
Photo of Andreonna

Andreonna

  • 1,040 Points 1k badge 2x thumb
Sure!

I have 4 tables

PM Checklists: _DBID_PM_CHECKLISTS
PM Tasks: _DBID_PM_TASKS
Checklist Templates: _DBID_CHECKLIST_TEMPLATES
Task Templates: _DBID_PM_ITEMS

The task templates pull into the checklist templates. 

There are 3 fields on the Task Template table. 
Task (FID: 6)
Section (FID: 7) 
Frequency (FID: 9)

The same 3 fields on the Task Template table are on the PM Tasks Table.
Task (FID: 6)
Section (FID: 7)
Frequency (FID: 8) 

The Checklist Templates Table has 2 fields that pull into the PM Checklists table.
Template Type (FID: 20)
Status (FID: 25)

These feed into the PM Checklists table fields
PM Type (FID: 139)
Status (FID: 138)

I believe the idea here is that on the Checklist Template table I would press a button called "Generate from this Template". This would trigger the Checklist Template to copy over into the 2 fields on the  PM Checklists table creating a new checklist. It would also pull the child records from the Checklist Template (which are actually from the Task Template table) over to the PM Tasks table and tie them to the PM Checklists table as child records. 

I hope I explained that well enough. 

Thank you!
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,512 Points 20k badge 2x thumb
This is helpful. I have a lot of other things competing for my time but this is easy enough to do step by step.

The information you provided is helpful but not quite what a developer would need to write the code. By parameterization I am referring to the set of parameters that would fully define what is to be copied from the target table to the source table. I am thinking this is the set of parameters that fully define the task:

var source = {
  dbidParent: "??????????",
  dbidChild: "??????????",
  clistParent: "20.25",
  clistChild: "6.7.9",
  relatedParent: "?"
}

var target = {
  dbidParent: "??????????",
  dbidChild: "??????????",
  clistParent: "139.138",
  clistChild: "6.7.8",
  relatedParent: "?"
}


I actually don't need you to fill in the question marks as I will just write a generic script and you can fill in the relevant values to drive your usage of the script. Note that the "length" of the clistParent and clistChild have to be of the same length (same number of periods). In some cases the values for the clistParent, clistChild, and relatedParent would be identical between the source and target if the tables had identical schemas.

So before I write the code just confirm that this makes sense to you.
(Edited)
Photo of Andreonna

Andreonna

  • 1,040 Points 1k badge 2x thumb
This does make sense to me. Thank you!
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,512 Points 20k badge 2x thumb
I might add a new property named xformChild (ie transform) to the source which would be some type of period separated string indicating what transform (ie calculation) to perform in mapping a source field to a target field. This would allow for the application of a function to perform some type of calculation but would most commonly be used to increment a counter or calculate a new date and deposit it into the corresponding target field.

For example, this set of parameters would perform an "identity" transformation (ie 
var source = {
  dbidParent: "??????????",
  dbidChild: "??????????",
  clistParent: "20.25",
  clistChild: "6.7.9", xformChild: "1.1.1",
  relatedParent: "?" }

While this set of parameters would indicate that the target field with fid=9 would receive an incremented value (1,2,3,4 ...):
var source = {
  dbidParent: "??????????",
  dbidChild: "??????????",
  clistParent: "20.25",
  clistChild: "0.6.7.9", xformChild: "Increment().1.1.1",
  relatedParent: "?" }
var target = {
  dbidParent: "??????????",
  dbidChild: "??????????",
  clistParent: "139.138",
  clistChild: "9.6.7.8",
  relatedParent: "?" }
I have to give some thought to how to specify dates that should be incremented in terms of a base date and an incremental number of days, weeks, months, workdates etc.
(Edited)
Photo of Andreonna

Andreonna

  • 1,040 Points 1k badge 2x thumb
I don't know that I need to be able to increment any fields. I really just need it to copy and paste into fields, like your first example. 
The QuickBaseClient.js SDK can be implemented within your .js file by using jQuery. This is of course assuming that you are referencing the script directly from your button. To do this, add your code between the following.



$(document).ready(function(){
    $.getScript("/js/QuickBaseClient.js", function(){
    
    // your code here

    });
});
(Edited)