Discussions

Expand all | Collapse all

Button to check a field and save the record (Submit button)

QuickBaseCoach Dev./Training09-14-2017 01:40

QuickBaseCoach Dev./Training09-14-2017 01:40

  • 1.  Button to check a field and save the record (Submit button)

    Posted 09-12-2017 20:07
    I want to put a "submit" button on my form that allows for:
    1. A checkbox field to be checked [Invoice Submitted]
    2. The record to be saved
    3. It must work whether or not it's a new record or one that has been saved before.
    4. I was using a formula-text  but formula-URL is fine that that's what I should be doing.

    I was trying to get it to update the field and save the record, but the code doesn't work, I believe because it has to be saved first

    var text Update=URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#]) & "&_fid_20=1"& "&apptoken= *********";  "<a id='saveButton' class='Vibrant Success' onclick='DoSaveAdd()' href='#'>Submit Invoice</a>"


  • 2.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:19
    I guess an if(IsNull([Record ID#]),
    would allow me to have two strings one for API_EditRecord and one for API_AddRecord but I don't understand how to get the AddRecord to work and then how to imbed the two options into the IF statement with correct Syntax. 


    I would think Javascript would make sense but I know little about Javascript. 
     
    Seems like Javascript would just check the box and hit the "save" button regardless of whether it was add to edit?



    ,


  • 3.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:22
    My suggestion is to just have the user save the record and then give them a button to "Submit", when in View mode.


  • 4.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:24
    That's feeling like the right answer at this point as this gets more and more complicated :(


  • 5.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:26
    I thought this code worked but now it won't. It saves but doesn't check the fid_20 to a true:

    var text Update=URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#]) & "&_fid_20=1"& "&apptoken= xxx";
    "<a id='saveButton' class='Vibrant Success' onclick='DoSaveAdd()' href='#'>Submit Invoice</a>


  • 6.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:29
    You are just guessing at code.  Well, I suppose that we all do that sometimes.  

    I don't know if there is a way to do what you ask without javascript, but that code certainly that won't work.

    You are defining the formula variable called "Update".  But then the actual code does not even refer to that formula variable.


  • 7.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:34
    You got me, but I'm leaning on the fly. It's not like I can quit my job and go to school for this stuff. Running a business and all...


  • 8.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:31
    Ah. I switched it from Formula-Text with HTML Checked to Formula URL and that works in view mode. I am then hiding the submit button in edit/add mode.

    var text URLONE = URLRoot() & "db/" & Dbid()& "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_20=1"& "&apptoken= xxxxx";

    var text URLTWO = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];
      
    $URLONE
    & "&rdr=" & URLEncode($URLTWO)


  • 9.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:33
    If you just want to edit the record to check a checkbox, yes that is easy.  


  • 10.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:34
    Do you also have a need to check that checkbox from a report but no want to have different buttons?


  • 11.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:37
    this syntax works well as long as there are no redirects in your URL

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


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


    The magic is that after it does the edit it will refresh the"page" whether that is a record or a report.


  • 12.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:51
    Edit: (just one = is enough!)

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


  • 13.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:38
    It wouldn't hurt to have it work from a report, allowing a user to submit from there after editing say multiple invoices. Do I use a formula text or URL type?


  • 14.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:38
    This is the only school there is for the type of questions you are asking.  There are a bunch of tricks to learn.  Once you learn them, you just keep re-using them.


  • 15.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:39
    Well you'd think I could at least have realized that I declared a variable and then never called it. :(


  • 16.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:40
    Be sure to give the button a pretty color.


  • 17.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:40
    formula URL


  • 18.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:45
    I did add to my report as well, and presto, like magic.


  • 19.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:44
    This is excellent. Thanks. I had to remove what appeared to be a stray "=" in the first assignment so it now looks like this. And yes, a green button was mandatory for this one :)

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


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


  • 20.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:50
    It even works if it was a button on an embedded report  of records on a record.  ie on a child table on a report on a record.


  • 21.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 01:52
    btw, what is your "day job" in real life?  What kind of business are you running?


  • 22.  RE: Button to check a field and save the record (Submit button)

    Posted 09-14-2017 20:53
    own/run a niche toy company: www.weebelievers.com