Forum Discussion

KarenHenke's avatar
KarenHenke
Qrew Cadet
2 years ago

Program Add button to view the record just added after save

Hello!

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 :) )

Thank you!



------------------------------
Karen Henke
------------------------------

4 Replies

  • DonLarson's avatar
    DonLarson
    Qrew Commander
    Karen,

    I like your solution and would like to see it.  Can you make a video and post it?

    As to another solution, I made a Customer Dashboard with a bunch of instructions that include Child Tables



    The screen shot does not show it, but I put the button bar with the Add Record in the last row of the dashboard.  This was my psychological play to make them at least scroll down the page before adding the record.


    ------------------------------
    Don Larson
    ------------------------------
  • Any reason why you're using API_GenAddRecordForm in particular?  API_GenAddRecordForm is usually used for opening an "add record" form with certain fields pre-populated.

    URLRoot() & "db/" & [_DBID_CUSTOMERS] & "?a=nwr" should open a new record in the customers table that will return you to the "view record" page for the customer when saved.

    ------------------------------
    Tyler Jablonski
    ------------------------------
    • KarenHenke's avatar
      KarenHenke
      Qrew Cadet
      Tyler!
      Thank you!!

      I copied that URL formula from another field and it didn't even occur to me to notice what kind of Add button I was copying (palm to forehead). 

      Ugh, I feel so silly - thank you again! 
      I updated the formula and it is working perfectly now.
      ~k

      ------------------------------
      Karen Henke
      ------------------------------
  • 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.

    ------------------------------
    Tyler Jablonski
    ------------------------------