Skip to main content
Question

how to create a ""submit"" button

  • July 10, 2019
  • 0 replies
  • 240 views

My users complete timesheets each week. Some work on it on an ongoing basis, saving as they go. I would like to give them a "submit" button that indicates that they are finished.

I assume this is as straightforward as having the button check a checkbox, but I'm not confident I have the code correct. I thought I'd ask here for confirmation, versus trial and error that will frustrate me. :)

This is modified from another button in another table that does multiple things. I copied the code that just does the checking the checkbox part. Is this it, or am I missing something that should go at the end?

URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=cpaz2k7njc4ifc24muhvc749ast&rid=" & [Record ID#]
& "&_fid_58=1"

(field 58 is the "submitted" checkbox)
This topic has been closed for replies.

  • Author
  • Registered
  • July 10, 2019
Update: I gave it a try, and the formula above partly works, in that clicking the button checked the checkbox. However, it brings me to a page that says the following:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<qdbapi>
<action>API_EditRecord</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<rid>266</rid>
<num_fields_changed>1</num_fields_changed>
<update_id>1562778829707</update_id>




</qdbapi>

  • Registered
  • July 10, 2019
That is the response page, telling you the api call worked fine. I believe there is a way to redirect them back to the previous page too. 

When I've done a draft system in the past I thought the simplest approach was the best. I added a checkbox named "ready to submit" at the bottom of the form near the save button. All my reports take that checkbox into account when they are looking for finalized records. That way they can save the record as many times as they want but it does not become "live" until they are ready and check that box. There might be a better way to do a drafts system but I have had no complaints so far about this one.

Sara, when you use an URL formula button to do an update of some kind, you need to decide where to land the user.  If you just run the API it will feel compelled to rely back with that success or failure message, which is no so user friendly.

If the button is being pushed in View mode and you just want to redisplay the record or report you can use this Syntax.


var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=cpaz2k7njc4ifc24muhvc749ast&rid=" & [Record ID#]
& "&_fid_58=1";

"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"




  • Author
  • Registered
  • July 14, 2019
Okay, so I have this button working great. Is there a way to have the button save the record too? As it stands, the user must first click save and close or save and keep working.

My users have an antipathy toward save buttons because they are used to a database which doesn't require that. So I'm looking for as many ways as possible to avoid that step.

If a form rule will do the trick too, that would be fine, but I haven't been able to figure one out.


URL Buttons can be a little tricky because Quick Base is re-directing the page and it injects its own save prompt when things have changed. 

That said - you can set up a new button that 'clicks' the save button for them using a rich-text formula that will work the same way from above with a little modification. 

So if your url-button does this now: 

var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=cpaz2k7njc4ifc24muhvc749ast&rid=" & [Record ID#]
& "&_fid_58=1";
"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"

Make a new Formula Rich Text and copy this: 

var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=cpaz2k7njc4ifc24muhvc749ast&rid=" & [Record ID#]
& "&_fid_58=1";
"<a class='Vibrant' href='#' onclick='" & 
"javascript: {" &
"$.get(\"" & 
$URL & 
"\");" & 
"$(\"#saveButton\").click();" & 
"}'" & ">CLICK HERE</a>"

This will make your editRecord call then save the page. I'd recommend if you go this route that you actually have 2 buttons - one for when they are on the 'View' versus 'Editing'. The reason is that when they're viewing this record, there is no save button to click - so its better to use Mark's version for 'viewing' so that the page still reloads

Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base