Forum Discussion

ChrisFaye1's avatar
ChrisFaye1
Qrew Cadet
5 years ago

Add Record Button that references current record & related record

Hi, 

I'm seeing if I can cut down on a few extra look-up fields. 

Currently, I have a button that will add a record in another table and copy the values from the current record into the created record. 

Here's a simple example of the action:
Add record......
Unit: Number fid=NewRecord Unit Number
Unit: Applicant Name fid=NewRecord Applicant Name
Property - Name fid=NewRecord Property Name  <<<<<Related Table Look-Up Field
Property - Address fid=NewRecord Property Address <<<<<Related Table Look-Up Field

Is there a way to avoid having to create the Look-up fields and rather simple tell the add record action to grab the local record info for some copied values and reference the related parent record for other copied values?


​​

------------------------------
Chris
------------------------------
  • I'm not sure I fully understand your question but in the target table where you are adding records if you make a relationship so that table is also related to the same parent as your source table then if you populate the field for [Related Parent] then you can have any look up fields from that Related Parent] come down to the newly created copied record as lookup fields.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • ChrisFaye1's avatar
      ChrisFaye1
      Qrew Cadet
      Thanks, Mark! 

      The trick here is we're using the button to create a carbon copy of the information rather than relate the new record because it needs to be frozen in time. 

      Sorry I misspoke on the add vs. edit record part.

      Here's a bit of the current button - 

      var text URLONE = URLRoot() & "db/" & Dbid()
      & "?act=API_EditRecord&rid=" & [Record ID#]
      & "&_fid_1784=" & URLEncode(UserToName(User()))
      & "&_fid_1783=true"
      & "&_fid_236=" & URLEncode("Application in Process")
      & "&_fid_1618=" & URLEncode([Property - Payment Structure])
      & "&_fid_1013=" & URLEncode([Property - Accounting Structure])
      & "&_fid_974=" & ([Property - Invoice Commission Rate]*100)

      Anything with "Property - " is a look-up field in the local table. It would be super-efficient if there was a way to avoid having the create the redundant look-up fields in the local table and instead have the button reference the fields in the related record on the parent table. 

      In written out terms - 
      var text URLONE = URLRoot() & "db/" & Dbid()
      & "?act=API_EditRecord&rid=" & [Record ID#]
      & "&_fid_1784=" & URLEncode(UserToName(User()))
      & "&_fid_1783=true"
      & "&_fid_236=" & URLEncode("Application in Process")
      & "&_fid_1618=" & <<<Look to Related Record in Property Table>>> URLEncode([Payment Structure])
      & "&_fid_1013=" & <<<Look to Related Record in Property Table>>> URLEncode([Accounting Structure])
      & "&_fid_974=" & <<<Look to Related Record in Property Table>>> ([Invoice Commission Rate]*100)

      ------------------------------
      Chris
      ------------------------------