Forum Discussion

AyoubSalhi's avatar
AyoubSalhi
Qrew Trainee
7 years ago

How can I create a record in a table when I click in a button of another table (with conserving some values)

I have a "Requisition" table, with a button "Make into Purchase Order".
Another table is "Purchase Orders" . I would like a button in the Requisition form when clicked, it would creates a PO with the same values.
 I added a "Req ID" in the PO Table, the Req Table also has a field "PO ID".

I'm trying with copyMasterDetailButtonHandler, but  can only duplicate the record in the same table. I want to copy it from 'Req table' to ' PO table'

13 Replies

  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    You can do it with a formula url button.  Either using the API_AddRecord or API_GenAddRecordForm.

    You will have to define the values that you want to copy, but that is pretty straight forward.  An example is what appears in any of your default "add" buttons.


    URLRoot() & "db/" & [_DBID_MESSAGES] & "?a=API_GenAddRecordForm&_fid_53=" & URLEncode ([Record ID#])& "&z=" & Rurl()

    Where the line:
    &_fid_53=" & URLEncode ([Record ID#])& "
    Is the information that is being written to the new form.
    • AyoubSalhi's avatar
      AyoubSalhi
      Qrew Trainee
      I couldn't make it work, I used API_GenAddRecordForm
      URLRoot() & "db/" & [_DBID_PURCHASE_ORDERS] & "?a=API_GenAddRecordForm&_fid_6=" & URLEncode ([Record ID#])& "&_fid_29=" & URLEncode ([Vendor])&  "&z=" & Rurl()
    • MCFNeil's avatar
      MCFNeil
      Qrew Captain
      I'm not 100% sure, but because the table [DBID_Purchase_Orders] is in a different app, you might have to hard code the dbid (i.e. bm4a6kyi8).

      Is it in the same domain?  i.e www.YOURCOMPANY.quickbase.com
    • AyoubSalhi's avatar
      AyoubSalhi
      Qrew Trainee
      Yes there are in the same domain, I'm able now to copy some fields, I figured out the 'fid' values was wrong. I'll try to copy the others and see what happens. Thanks
  • Ayoub,
    When you say it does not work, what are the symptoms of the problem.  What is the error message?
    • AyoubSalhi's avatar
      AyoubSalhi
      Qrew Trainee
      I'm able now to copy some fields now, I figured out the 'fid' values was
      wrong. I'll try to copy the others and see what happens. Thanks
    • AyoubSalhi's avatar
      AyoubSalhi
      Qrew Trainee
      What I wasn't able to copy is 'foreign keys' of other tables from the "Requisition" table.
      per example, I have a "Vendor" table that has a relation with the "Requisition" table containing many lookup fields :
      I have another table "Requisition Items" which i'm using a report of it in my requisition form :


      I am not able to copy the data of the vendor & Requisition items from "Requisition" table to "PO" table .  Even that I specified the fields in the formula :
      URLRoot() & "db/" & [_DBID_PURCHASE_ORDERS] & "?a=API_GenAddRecordForm&_fid_34=" & URLEncode ([Requisition items])& "&_fid_10=" & URLEncode ([Purchase Authority])& "&_fid_9=" & URLEncode ([Descrition])& "&_fid_11=" & URLEncode ([Contract #])& "&_fid_73=" & URLEncode ([Vendor])& "&_fid_18=" & URLEncode ([Voucher #])& "&_fid_19=" & URLEncode ([Voucher Date])& "&_fid_14=" & URLEncode ([Authorized By])& "&_fid_15=" & URLEncode ([Authorization Date])& "&_fid_12=" & URLEncode ([Requested By])&"&_fid_54=" & URLEncode ([Creation Date])& "&_fid_90=" & URLEncode ([Order #])& "&_fid_53=" & URLEncode ([Vendor])&"&z=" & Rurl()
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Can you better explain your question, as i cannot understand it.

      Also, I cannot help deciphir any syntax errors in your formula, if that is a problem as its all written on one long line


      I suggest that you write your formuals vertically like this
      URLRoot() & "db/" & [_DBID_PURCHASE_ORDERS] & "?a=API_GenAddRecordForm"
      & "&_fid_34=" & URLEncode ([Requisition items])
      & "&_fid_10=" & URLEncode ([Purchase Authority])& "&_fid_9=" & URLEncode ([Descrition])
      & "&_fid_11=" & URLEncode ([Contract #])
      & "&_fid_73=" & URLEncode ([Vendor])
      & "&_fid_18=" & URLEncode ([Voucher #])
      & "&_fid_19=" & URLEncode ([Voucher Date])
      & "&_fid_14=" & URLEncode ([Authorized By])
      & "&_fid_15=" & URLEncode ([Authorization Date])
      & "&_fid_12=" & URLEncode ([Requested By])
      &"&_fid_54=" & URLEncode ([Creation Date])
      & "&_fid_90=" & URLEncode ([Order #])
      & "&_fid_53=" & URLEncode ([Vendor])
      &"&z=" & Rurl()

      Please explain what the symptoms of the problem are.  Do you have a syntax error?  or what is not working.

      Also out of the blue you mention a PO table.  Does that table have a relationship to any of your other tables.?