Forum Discussion

LoranPrince's avatar
LoranPrince
Qrew Member
2 months ago

Copy Master detail records from a button based upon a selection on the form

I am wanting to import or copy a set of master records from a template job(one of many so I need to be able to select before I push the button) , The selection being made on the jobs form. This process was working before they made code pages the only place you can run javascript code.  The formula i Used before is this

URLRoot() & "db/" & [_DBID_JOBS] & "?a=API_GenAddRecordForm&_fid_18=" & URLEncode ([Contact info ID#])& "&z=" & Rurl()

This code still works in another app but the 18383 is the reference to the Job that the detail records are to be copied from.  

I am having problems getting the code pages to even show up on the form as a button.

What am I doing wrong?



------------------------------
Loran Prince
------------------------------

11 Replies

  • MarkShnier__You's avatar
    MarkShnier__You
    Qrew #1 Challenger

    np,

    The API you posted is the one that can be used to put up an Add Record form to duplicate a record that you are sitting on, but it will not copy Children.

    I am going to assume that your template child records are from Template Parent records of the same table you are on.  ie you do not have a different tables for your templates, just the same tables for parent and children,  but some of the Parents are special template record., 

    While there is an API to copy parents and children here's what I suggest you do for the best user experience.

    Go to the settings for the application and then Application management and then locate the link to the wizard which will create a button for you.  Initially, just elect the option to copy the Children form the current Parent.

    It will look like this

    "javascript:void(copyMasterDetailButtonHandler('&copyFid=8&destrid=0&sourcerid=" & [Record ID#] & "', 'xxxxxxxxx'))"

    Then edit it to look like this.

    "javascript:void(copyMasterDetailButtonHandler('&copyFid=8&destrid=0&sourcerid="

    & [Record ID# of the Parent template record] 

    & "', 'xxxxxxxx'))"

    In order to have a field for which Parent's template children to use [Record ID# of the Parent template record] , I suggest that you make a relationship of the Parent table to itself, so the user can select the Template parent.  The reason I suggest using this wizard which has permissible JavaScript, instead of the API format  is that it has a nice behaviour in that once it creates the new parent it offers the option to the user to land on the new parent which is typically what they want.



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • LoranPrince's avatar
      LoranPrince
      Qrew Member
      Hey good morning Mark, Thanks so much for your help. I know you are the most knowledgeable guy there!!!!

      I used to come to your big events when you had them live. 

      The button works, however. You are correct about the templates being on the same table.  
      The code they way I set it up does copy the child records and the grandchild records. 
      the code is 
      "javascript:void(copyMasterDetailButtonHandler('&relfids=33&sourceRID=57&destrid=" & [Contact info ID#] & "', 'bt37k7pc8'))"

      I think 57 refers to the job that the tasks are copied from. 

      I would like to have the code refer to a differing job based upon a choice made on the form thereby choosing which template to copy.  

      How would I set that up to make that choice and show the RID for the differing job to copy from? I can see that a loop may be formed.  

      There is a way I think but how without the loop?





      Loran Prince

      Prince Finishing Inc

      Edmonton's Premier Finishing Company

      780-700-9057

      8420 34A ave

      Edmonton AB T6K 0C2

      greatservice@princefinishing.com

      princefinishing.com

       

       



      • MarkShnier__You's avatar
        MarkShnier__You
        Qrew #1 Challenger

        Can you tell me how many Parent Template records you have.  If it's not too many, one solution is to just have a multiple choice field with the say 10 choices and then a hard coded calculation formula to calculate which Record ID to pull from. 

        In rethinking my suggestion, there is the possibility that if the related the table to itself in order to pull in the parent template record ID, the copy parent child may not allow that kind of what they call looping relationship.  

        so you an have a field like

        Case([Project Type],

        "Big", 123",

        "Small", "124",

        "Custom", "125")



        ------------------------------
        Mark Shnier (Your Quickbase Coach)
        mark.shnier@gmail.com
        ------------------------------