Forum Discussion

SarahClark's avatar
SarahClark
Qrew Cadet
6 years ago

how to create a ""submit"" button

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)
  • 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>
  • AustinK's avatar
    AustinK
    Qrew Commander
    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.
    • SarahClark's avatar
      SarahClark
      Qrew Cadet
      That would indeed be simpler. However, these are all new users (we're just rolling out Quick Base) and it's easier for them to understand a big colorful button that they can access in either view or edit. Simple for them trumps simple for me.
  • 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);"



  • 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
    • SarahClark's avatar
      SarahClark
      Qrew Cadet
      Thank you. I tried this and it didn't work -- it made the button, but it didn't do anything when I clicked it.

      In any case, I'm looking to do things in the opposite order - save the record first, and then have the button do whatever else it does. As it stands, if you click the button before you've saved, it gives them error messages they don't know what to do with. I've got a text on the form that says "Save any changes before clicking submit," and that may be the best I can do, but in my perfect world I'd have a button for them to "save and submit.
    • ChayceDuncan2's avatar
      ChayceDuncan2
      Qrew Cadet
      I guess reading this through again I have a different question. Is there a way you can eliminate the button altogether - and instead use an automation? With the above button I copied you should be able to just put the snippet $(\"#saveButton\").click(); as the first part of your javascript so the save occurs first. 

      Is there something specific about this button that can be accommodated by having them just save the record like they normally would - and then use an automation to make whatever final changes you need?

      Chayce Duncan | Director of Strategic Solutions
      (720) 739-1406 | chayceduncan@quandarycg.com
      Quandary Knowledge Base
    • SarahClark's avatar
      SarahClark
      Qrew Cadet
      The user would still need to do something proactive to indicate "I'm done" - whether it's checking a box manually or clicking a button.

      The simplest solution would be to have them check the box manually when they are done and then Save and Close one last time. But for various reasons, a button is better for my users.