I did some testing on my own and it looks like if you have an API_GenAddRecordForm link in a formula URL field, Quickbase is automatically appending "&masterRid=[Record ID#]" to the end of it. This returns you to the master record even if you didn't put "&z=Rurl()" at the end of your link. I don't remember it working like this in the past, but maybe I'm remembering wrong. Either way, not a huge fan of this.
The workaround is to use a formula rich text field instead, which should look like this:
var text url = URLRoot() & "db/" & [_DBID_CUSTOMERS] & "?a=API_GenAddRecordForm";
"<a href='"&$url&"' class='Vibrant'>New Customer</a>"
Quickbase will not apply the masterRid URL parameter if the link is in a rich text formula field.
A neat idea to expand on your original solution would be to create a checkbox field in the customers table called "Opened from search" that's hidden from the add record form. You can use API_GenAddRecordForm to set the checkbox equal to yes when you click on the button in the search table. Then you can add a custom data rule in the customers table to display an error message if the user is in a certain role and the checkbox isn't checked. This would prevent users from going directly to the customers table and adding a record without searching first.
Sent: 01-09-2023 12:00
From: Karen Henke
Subject: Program Add button to view the record just added after save
I have a table of customers. Users are able to add customer records, but not edit them.
Before they are able to add a new customer record, I want to 'force' them to search existing customer records to make sure they aren't creating a duplicate.
If the customer record is found, they can select it to view the record.
If the customer record is not found, they need to be able to add a new customer record.
There may be a much easier way of doing this - and if so, please let me know - but this is how I have it set up right now....
I've set up a Search table and connected it to the Customers table.
Customers = parent; Search = child.
From our home page, the user clicks the Search customers button which opens a new Search record.
They are presented with a dropdown list of Related Customer records where they can search for the customer they are looking for.
If they select a customer from the list, they are shown related customer fields which will help them identify if this is the customer they were looking for or if they need to create a new customer record.
Under those related customer fields is a question, "Is this the customer you were searching for?" with required yes/no response options.
If they select yes, a button that launches that customer record is presented.
If they select no, a button that launches a new customer record is presented.
After they complete and save the new customer record, I want them to stay on the new Customer record (in view mode).
This is the first formula I used for the add button:
URLRoot() & "db/" & [_DBID_CUSTOMERS] & "?a=API_GenAddRecordForm"& "&z=" & Rurl()
After searching the discussion forum, I removed the last bit in the hopes that it would keep me on the child record (the new Customer record), but this one also takes me back to the Parent record (in edit mode):
URLRoot() & "db/" & [_DBID_CUSTOMERS] & "?a=API_GenAddRecordForm"
Would love thoughts on how to update the formula so it works the way I need it to (or thoughts on how this process could be simplified :) )