Quick Base Formula URL for multiple actions

In Quick Base, you can create buttons using Formula URL fields to trigger multiple actions – however, it’s complicated. A reminder for myself in case I ever need to set something like this up again – this formula adds a record to a child table, updates a field on the current table and immediately re-displays the form in “view” mode using a series of URL encoded ‘chunks’ that are all strung together at the end:

var text AddChildRecord =
URLRoot() & "db/" [_DBID_XXX]
& "?a=API_AddRecord&_fid_nn="& URLEncode([Record ID#])
& "&_fid_nn="& URLEncode("Add Text Here")
& "&_fid_nn="& URLEncode(User())
& "&_fid_nn="& URLEncode(Today())
& "&apptoken=9jabnbdh53n9gd4kwhxa7s8gn1";

Because we’re using the API_AddRecord function to add a record to a child table, you have to specify the DBID. To find the DBID alias, go into the Settings for the child table, then select Advanced Settings and scroll to the bottom of the page. Record ID will need to be updated to reflect what records are called in that table (unsure whether this needs to be passed through the URLEncode function or not – but it works).

The &_fid_nn items are form fields (nn is the field ID); to find these, go to Settings for the child table, then select Fields under table structure. Hover your mouse over the field name to see the field ID.

The last line is only required if app tokens are enabled for the Quick Base app.

var text EditRecord =
URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_nn=" & URLEncode("Yes")
& "&apptoken=9jabnbdh53n9gd4kwhxa7s8gn1";

Editing a record in the existing table using the API_EditRecord function is much easier. Use the Dbid() function to specify the current table, specify the changes you want and add an apptoken if needed.

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

This displays the record again using the same form. Here’s a breakdown of what each bit means:

URLRoot()Go to https://mycompany.quickbase.com/
& “db/”Add the “db/” you see in all URLs
& Dbid()Add the Table ID you are currently on
& “?a=dr&rid=”This says “Action = Display Record and Record ID = …”
& [Record ID#]Specify the Record ID to display
$AddChildRecord
& "&rdr=" & URLEncode($EditRecord)
& URLEncode("&rdr=" & URLEncode($Display))

String everything together – note the nested URLEncode functions and the lack of a semicolon at the end.