Skip to main content
Question

How do I create a button on a form that will save the current record, copy some of the fields to a new record, and redisplay the new record in edit mode?

  • August 5, 2015
  • 0 replies
  • 382 views

How do I create a button on a form that will save the current record, copy some of the fields to a new record, and redisplay the new record in edit mode?
This topic has been closed for replies.

This can be done natively except not the initial Save. You would need to be in View Mode having saved the record.

  • Author
  • Quickbase Alumni
  • August 5, 2015
Okay I can work with that....

Actually sorry, I need to take that back.  The choices are either to push a button to put up an Add Record Form with some of the fields filled in and then user would do any additional data entry and save, or alternatively push a button to create the copied record and display it, but not be in edit mode.

  • Author
  • Quickbase Alumni
  • August 5, 2015
Okay, let's try the first option.

There are two ways to go here. Low Tech and high Tech.

Low Tech

You will notice that when you use the More button while viewing a record and click to Copy this Record, the URL you see looks like this


mycompany.quickbase.com/db/xxxxxx?a=GenCopyRecord&rid=770

So the low tech solution is just to make a URL formula button to make that URL

The formula would be

URLroot() & "db/" & dbid() &  "?a=GenCopyRecord&rid=" & ToText([Record ID#])

When you use that option by default all the data entry fields on the form will copy across to an Add Record Form.  If you do not want certain fields to Copy across then you individually go to each field that you do not want to copy across and uncheck the property

Auto-fill Copy the value when using "Copy this Purchase Order" to add a new Purchase Order

The best way to quickly get to the field Properties is to right click near the field on the form.

The only downside of this method is that if any fields on the form are set to be Read Only or are not visible on the form, I don't think that they will copy across.

Higher tech

So the more reliable way would be to use an API

Here is an example

URLRoot() & "db/" & Dbid() & "?act=API_GenAddRecordForm"
& "&_fid_12=" & [Purchase Order #]
& "&_fid_42=" & URLEncode([Component or Bulk item?])
& "&_fid_38=" & [Related Bulk item Master]
& "&_fid_24=" & [Related Component]
& "&_fid_28=" & ToText([Line Item Cost Override])
& "&_fid_53=" & URLEncode([PO Line Comment])

Note that when you use this method you are building a URL, and URLs may not have spaces or specials characters in them.  So where there might be a strong that you are putting into a field, which might have special characters or spaces you need to URLEncode as I have done above.  The "fid's" are the field ID numbers.

Lastly, if you did decide that you wanted to actually create the record and display it to the user, then you could do this

URLRoot() & "db/" & Dbid() & "?act=API_AddRecord"
& "&_fid_12=" & [Purchase Order #]
& "&_fid_42=" & URLEncode([Component or Bulk item?])
& "&_fid_38=" & [Related Bulk item Master]
& "&_fid_24=" & [Related Component]
& "&_fid_28=" & ToText([Line Item Cost Override])
& "&_fid_53=" & URLEncode([PO Line Comment])
& "&disprec=1"


 



  • Author
  • Quickbase Alumni
  • August 5, 2015
Thank you!  I'm almost there..... I'm running into one problem.  I went with the high tech scenario option 1 - here is my formula:  

URLRoot() & "db/" & Dbid() & "?act=API_GenAddRecordForm"
& "&_fid_85=" & URLEncode([PO # (on PO form) - Lookup])
& "&_fid_23=" & URLEncode([Item Number (on ITEMS form) - Lookup])
& "&_fid_6=" & [Inspector]

Field 23 is not populating.  It's a look up field that relates the inspection back to the item being inspected.  Any idea why that isn't populating?  FID 85 is also a look up field and that one is populating correctly.  Could it have something to do with the relationship between those 2 fields?

Glad you are getting close.  We will have you being an API whiz before you know it.

You cannot populate a lookup field.  So what you need to find is the field [Related Parent] for where the lookup came from - ie the "reference field' on the right side of the relationship and populate that field.  Then ALL the lookups for that relationship will come down automatically.

  • Author
  • Quickbase Alumni
  • August 5, 2015
I don't know about being a whiz but I'm atleast at novice level now! I found the correct reference field and it's now working. Thank you for your help!

yay! Well done.

Instead of copying the information to a new record, is it possible to copy data in specific fields to an entirely different form?

Yes, you can click a record in one table and pop up an Add Record form in another table.  Just change the part of the formula which identifies the [_DBID_ of the table]

So in the formula, the &"&_fid_6=" would be the field ID for the new record on form "B"? while the string next to it: & [Inspector] would be the field of the pre-existing record on form "A"?

Exactly!

I'll give it a shot, Thanks!

  • Quickbase Alumni
  • July 13, 2018
Thank You Mark, great solution.