Forum Discussion

ThomasOtten1's avatar
ThomasOtten1
Qrew Member
10 months ago

Really Dumb Question - Button to Create Record?

Hey Y'all.

Long story short, I want a button that does the same thing as hitting save & close - it creates the record if there isn't one, and then lets you see the record in edit mode. I can't find a button in magic buttons that does this. Ideally, I'd then build out the functionality to set the field ID 40 = 1, but that is substantially easier than trying to figure out how to build a button that exists already in QB into the edit version of a doc.

This is so an employee can just click "save and submit for approval". It's more work than it needs to be to save one click, but I'm surprised I can't find documentation for this ask.



------------------------------
Thomas Otten
------------------------------

4 Replies

  • I'm sure I can help you with this. Once the user presses your button, where do you want to land the user?



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • ThomasOtten1's avatar
      ThomasOtten1
      Qrew Member

      Ideally, to the view page of the record that was just created. If that's tough to do dynamically, probably just the app dashboard. Or I could maybe a page ID to the table the record and send it there.



      ------------------------------
      Thomas Otten
      ------------------------------
  • It's not a dumb question and it's actually a bit tricky.

    There is relatively new functionality which will only work in a Rich Text formula field (not a Formula URL field type).  It uses a special parameter called  %%rid%% and that in combination with the SavedBeforeNavigating Will cause the record to first save and it allows the formula to grab the value of the newly established Record ID, and then continue with the rest of the URL.

    Another tricky part is that the %%rid%% does not like getting URLEncoded.

    Note that this will only work if the record is "dirtied" by the user - ie they have done some data entry and the Advanced Properties for the table is set to Auto save when navigating away.

    var text RID = If([Record ID#]>0, ToText([Record ID#]), "%%rid%%");
     
    var text SetCheckbox = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & $RID
    & "&_fid_40=1";
     
    var text DisplayRecordNoRID = URLRoot() & "db/" & Dbid() & "?a=dr&rid=";
     
    var text URL = 
    $SetCheckbox
    & "&rdr=" & URLEncode($DisplayRecordNoRID) & $RID;
     
     
    "<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #117a39; border-radius: 5px; color: #FFFFFF; display: inline-block; padding: 4px 4px 4px 4px; width:140px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 12px \"href='"
    & $URL
    & "'>Submit</a>"

     



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • ThomasOtten1's avatar
      ThomasOtten1
      Qrew Member

      Wow! Tossed my app token at the end of the Var Text line and it worked like a charm!

      Thanks so much Mark!



      ------------------------------
      Thomas Otten
      ------------------------------