Create "Save" button that saves the record and then displays record in view mode

  • 0
  • 1
  • Question
  • Updated 6 months ago
  • Answered
I want to create a simple "Save" button which saves the new record and then displays it in view mode.  Their doesn't seem to be an API command that does this.  This must be super simple, but I am not strong in the "code department."
Photo of Taury Anderson

Taury Anderson

  • 170 Points 100 badge 2x thumb

Posted 6 months ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
this code as a formula Rich text field will make an extra save button to put on your form.

"<a id='saveButton' class='Vibrant Success' onclick='DoSave()' href='#'>WhatEverYouWantYourButtonToSay</a>"

The colors can be controlled by the words. Ignore the formula, I'm just showing you the colors available.  But I think that the success which used to be green got turned into blue when we had the purple day rebranding at Quick Base a few months ago.



List("&nbsp;",
    "<a class='Vibrant'>Vibrant</a>", // regular grey button
    "<a class='Vibrant Alert'>Vibrant Alert</a>", // yellowish
    "<a class='Vibrant Danger'>Vibrant Danger</a>",  // red
    "<a class='Vibrant Primary'>Vibrant Primary</a>", // blue
    "<a class='Vibrant Snowy'>Vibrant Snowy</a>",  // white
    "<a class='Vibrant Success'>Vibrant Success</a>" // green


Photo of Taury Anderson

Taury Anderson

  • 170 Points 100 badge 2x thumb
Thank you!  Works like a charm.  Now, what if I want to end up at the "view" mode of the record I just saved?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
I don't understand. is the issue that you are landing back on a report after adding a record. Where are you landing that is a problem.  Where are you launching the Add Record from?
Photo of Taury Anderson

Taury Anderson

  • 170 Points 100 badge 2x thumb
I am launching the "Add Record" from a Parent table (Properties) URL button to create the new child record "Work Order". 
In "Work Order, I have placed my new save button. 
When I click the new save button, I want to end up looking at the record that I just saved (rather than the Parent record from which it was created)

Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
The fix is to change your ad child button. Can you post your code for at child and I’ll show you how to fix it.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
URLRoot() & "db/" & [_DBID_WORK_ORDERS]
& "?a=API_GenAddRecordForm&_fid_20=" & URLEncode ([Record ID#])
& "&_fid_44=" & URLEncode([Address Code]) 
& "&_fid_236="& URLEncode(1)
& "&_fid_248="& URLEncode("Estimate")

Photo of Taury Anderson

Taury Anderson

  • 170 Points 100 badge 2x thumb
I realize that this is what I would put in there if this were a formula-URL type field, but you original solution is for script that is used in a formula-rich text field (right?  this is how it is working now).  BUT, I need both of these things to happen when the one button is clicked:
  • fid 248 contents changes to "Estimate"
  • The new record is then saved
Perhaps I am missing how what field type you are intending me to be using and how I can combine the two pieces of script:
  • "<a id='saveButton' class='Vibrant Success' onclick='DoSave()' href='#'>WhatEverYouWantYourButtonToSay</a>"
  • URLRoot() & "db/" & [_DBID_WORK_ORDERS]
    & "?a=API_GenAddRecordForm&_fid_20=" & URLEncode ([Record ID#])
    & "&_fid_44=" & URLEncode([Address Code]) 
    & "&_fid_236="& URLEncode(1)
    & "&_fid_248="& URLEncode("Estimate")



Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
There is no need to use that extra save button, unless for some reason, having the green save button on both the top and the bottom of the form is not enough for your users and they need three!! save buttons on the form.

The code I provided will launch the ADD record form and pre-populate fid 248 with "Estimate".
Photo of Taury Anderson

Taury Anderson

  • 170 Points 100 badge 2x thumb
I do in fact need a button that does that.  At the bottom of the table, we want to make two different save buttons:

Save as Work Order
Save as Estimate

I realize that we could manually choose one for the type field and then click save  - that would be the obvious thing to do.  I have had this sort of request before, so I figured I would try and see if you could feed me the code to make it happen.

Are you saying that is can't be done within a single formula-rich text button?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
Sorry, I do not know if its possible to make an update to the form while saving.  I don't believe that it can be done without non native scripting.

Tarury, What you described is the default behavior of the add new record button that you see on the table home page. The URL behind it is db/<dbid>?a=nwr


This is designed to save the new record and then open it in view mode.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
Tauray

Are you launching off a parent record to add a child or are you launching off the dashboard?
Photo of Taury Anderson

Taury Anderson

  • 170 Points 100 badge 2x thumb
I am not launching off the dashboard - it must be created from the parent record.