Skip to main content
Question

Copying the Children of a Parent only (Code Assistance needed)

  • January 8, 2021
  • 0 replies
  • 64 views

Forum|alt.badge.img+6
Currently working on a new app for our company in which I am changing some items and reusing or rebuilding others.

I ran into an issue with a URL button.  What I need it to do is copy the related children of a parent (but NOT the parent) then related said new copies to the work request the user is in.  Basically the chosen type is holds the "templates" and the copies will become the "live" records.

At a high level, this is what I need.
  • Children of the Related Staging Type are copied
  • The fresh copies are related to the Request and Job.
  • The fresh copies have their template checkbox deselected and the service date put in.  This filters them from the original templates.
  • Once done, the script should return the user to the request so they can check the data.

Here is what I have so far based on the old code from the old app.  Note that I replaced the table ID's with simple names just for the ease of this discussion, the actual code has the real values.  Lastly, note that the "Transactions" items have been commented out as I do not know if I will need them, so i am keeping them commented for now.

When I run this code, I just get a "page cannot be found" error.  Any ideas?  This code is almost identical to the old one except that the old one has one less set of actions and no comments...

//Java Magic? (Copies the Children, does NOT copy parent [hopefully])
    "javascript:void(window.open('" & URLRoot() & "db/" & Dbid() & "?a=dbpage&dbid=" & "Parent Table"
        & "&pagename=copyParentChild-Select.html&onlyDBIDs=FINACIALS.COSTS.CONFIGS.TRANSACTIONS&rid=" & URLEncode([Related Project Staging Type])


//Related the Children to the Staging Request
    & "& dest=refresh&destrid=null & FINACIAL-43=" & URLEncode([Staging ID]) //Relates Financials to the Staging Request
    & "& COSTS-49=" & URLEncode([Staging ID]) //Relates Costs to the Staging Request
    & "& CONFIGS-31=" & URLEncode([Staging ID]) //Relates Configs to the Staging Request
//    & "& TRANSACTIONS-24=" & URLEncode([Staging ID]) //Relates Transactions to the Staging Request

//Relates the Children to the Job
    & "& FINACIALS-44=" & URLEncode([Related Job])  //Relates Financials to the Job
    & "& COSTS-34=" & URLEncode([Related Job])  //Relates Costs to the Job
    & "& CONFIGS-32=" & URLEncode([Related Job])  //Relates Configs to the Job
//    & "& TRANSACTIONS-17=" & URLEncode([Related Job])  //Relates Transactions to the Job

//Encodes Today's Date, and Unchecks Template
    & "& FINACIALS-34=" & URLEncode(Today())  //Relates Financials to the Job
    & "& FINACIALS-33=" & URLEncode(false)  //Unchecks Template in the Financials
    
    & "& COSTS-35=" & URLEncode(Today())  //Relates Costs to the Job
    & "& COSTS-31=" & URLEncode(false)  //Unchecks Template in the Costs
    
    & "& CONFIGS-33=" & URLEncode(Today())  //Relates Configs to the Job
    & "& CONFIGS-34=" & URLEncode(false)  //Unchecks Template in the Configs
    
//    & "& TRANSACTIONS-17=" & URLEncode(Today())  //Relates Transactions to the Job
//    & "& TRANSACTIONS-17=" & URLEncode(0)  //Unchecks Template in the Transactions

//Creates the window?
    & "','copyRecursive','top=240,left=320,width=400,height=150,location=no,menubar=no,toolbar=no'))"​


------------------------------
John Ross
------------------------------
This topic has been closed for replies.

MarkShnierYou
Forum|alt.badge.img+24
The best approach is to scrap that code page.

There is an API for CopyMasterDetail.  https://help.quickbase.com/api-guide/understandreference.html

The User would select a Template Project which holds the correct child tasks and import them into the current record that the user is on.  There is no need to use a code page.

It's a simple URL formula field.  Give it a try and post back if you get stuck or contact me for some quick consulting help of about an hour.

The final formula will look something like this

var text Import = URLRoot() & "db/" & Dbid() & "?act=API_CopyMasterDetail"
& "&relfids=65" // relationship report link field to the correct child table
& "&destRID=" & [Record ID# of Template Project] // source of he children
& "&sourcerid=" & [Record ID#];  // destination of he copied children is the record we are sitting on.

var text DisplayProject = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID# of Template Project];


$Import
& "&rdr=" & URLEncode($DisplayProject);




------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------