Discussions

Expand all | Collapse all

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

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

    Posted 06-16-2017 19:28
    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!!


  • 2.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Top
    Contributor
    Posted 06-19-2017 12:10
    That SDK is outdates yes, but you just need to reference it in you code and it still should work just fine.


  • 3.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Posted 06-19-2017 13:34
    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. 


  • 4.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Top
    Contributor
    Posted 06-19-2017 12:23
    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.


  • 5.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Posted 06-19-2017 13:35
    I read all of those things. But I don't have any other suggestions to move forward with what I need. 

    Any ideas?


  • 6.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Top
    Contributor
    Posted 06-19-2017 13:46
    I am catching up with my shadow and have another busy week so my answers have to be short.

    Can you generalize your problem in terms of what parameters would define the operation you want to carry out? They might even be the same parameters as the code I am telling you not to use but I don't the the time to search that source code. What I need to know are parameters such as the source and target dbid's, the clist of fids to be copied, and the related parent fid in the child table. It is easy to write the code but some thought has to go into identifying the parameters needed to define the task to be accomplished.


  • 7.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Posted 06-19-2017 15:07
    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!


  • 8.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Top
    Contributor
    Posted 06-19-2017 16:29
    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.


  • 9.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Posted 06-19-2017 16:38
    This does make sense to me. Thank you!


  • 10.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Top
    Contributor
    Posted 06-19-2017 17:21
    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.


  • 11.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Posted 06-27-2017 20:06
    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. 


  • 12.  RE: Javascript SDK - Copy Parent and Child records to two new tables

    Posted 06-19-2017 14:41
    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

        });
    });