Forum Discussion

RaymondSakar's avatar
RaymondSakar
Qrew Cadet
2 years ago

Can you check a checkbox and then add a record?

Hi QB Community, I'm wondering if its possible to check a checkbox via a button and then save a new record. The workflow is:

Complete fields on Add form and click a 'Save & Continue' rich text formula button. The button uses the save before navigating class. Upon clicking the button it would also check a checkbox on the form, which would then trigger a pipeline.

As of now, the record is saving but the checkbox not checking. I'm wondering if it's not possible because you can't edit a record that hasn't been added?


This is the code I am using...

var text rid =
If([Record ID#]>0,
ToText([Record ID#]), // Record ID already exists
"%%rid%%" // New record, no Record ID exists yet
)
;
var text url = URLRoot() & "db/" & Dbid() & "?a=er&rid=" & $rid & "&_fid_18=1";
var text ButtonWords = "Save and Continue";
 
// Begin button style
var text bgcolor = "#6BBD57"; // green
var text txtcolor = "white";
var text style = "class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration: none; text-align: center; background:" & $bgcolor & "; border-radius: 5px; padding: 5px 7px; color: " & $txtcolor & "; display: inline-block; font-size: 125%; font: normal 700 16px/1 \"Calibri\", sans-serif; text-shadow: none;";
// End button style
 
"<a " & $style & " href=" & $URL & ">" & $ButtonWords & "</a>"


------------------------------
Raymond Sakar
------------------------------

1 Reply

  • There are three issues.  BUt before I exp0lain I'm assuming that you want to land the user on the record in edit mode as you called the button Save & Continue....

    The first is that you are confusing 
    ?a=er
    with
    ?a=API_EditRecord


    The former will put a record into manual edit mode for the user to do data entry (and it does not support populating fields) and the latter, will actually instantly edit the record.

    The second issue will be that the %%rid%% does  not like to be URLEncoded, so we need to contrive to keep it out of the URLEncode's parentheses.
     
    The last is that when you run an API, you need to land the user somewhere or else the success or failure of the API call will be spewed onto the screen.  So I'm making the assumption that you want to land the user on the record in Edit mode.

    Note also for this technique to work, the user or a form rule needs to edit the record so it's dirty, thus forcing the save and you need to have the table's Advanced settings set to 

    "Auto save when directed away from the page".  All new apps default the setting this way but just in case you're working with a very old app.

    Try this

    var text rid= If([Record ID#]>0,
    ToText([Record ID#]), // Record ID already exists
    "%%rid%%"); // New record, no Record ID exists yet
     
    var text EditRecord =  URLRoot() & "db/" & Dbid()
      & "?a=API_EditRecord&_fid_18=1&rid=" & $rid; 
     
    var text DisplayInEditMode =  URLRoot() & "db/" & Dbid() & "?a=er&rid="; // we don't supply the $rid here because we want it outside the URLEncode
     
    var text URL = $EditRecord
    & "&rdr=" & URLEncode($DisplayInEditMode) & $rid;
     
    var text ButtonWords = "Save and Continue";
     
    // Begin button style
    var text bgcolor = "#6BBD57"; // green
    var text txtcolor = "white";
    var text style = "class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration: none; text-align: center; background:" & $bgcolor & "; border-radius: 5px; padding: 5px 7px; color: " & $txtcolor & "; display: inline-block; font-size: 125%; font: normal 700 16px/1 \"Calibri\", sans-serif; text-shadow: none;";
    // End button style
     
    "<a " & $style & " href=" & $URL & ">" & $ButtonWords & "</a>"


    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------