Forum Discussion

JuanSolorio1's avatar
Qrew Cadet
3 years ago

Custom Save and Close button

Hello everyone,

This is probably a super simple solution but for the life of me I have not been able to get it to work. I am trying to create a custom button that simply saves the record on a form that has both the parent and the child records in edit mode.

A parent record form has an embedded grid of related child records. When the parent record is in edit mode, the grid of child records is editable, so that the user can add or modify the related child records. At this point, the parent record has already been saved, so the record ID of the parent already exists.

All I want my button to do is to save any changes made to both/either the parent or the child records. I want this button to work exactly like Quickbase's native "save & close" button.

Thanks in advance for your help!

Juan Solorio

5 Replies

  • This happens Natively if you have the Table set to AutoSave when redirecting away from the Page.
    If you really want a button, just create a formula-rich text field that navigates to View the current record.

    Tammie King
    • MarkShnier__You's avatar
      Icon for Qrew Legend rankQrew Legend
      It's actually a bit tricky to make a button. @Sharon Faust told us the trick here.

      The issue is that if the only changes are to the grid edit child records and not to the parent record, the a button to redisplay the record will cause a pop up which will confuse the users.  Also you want this to work on Add mode presumably too.

      var text RID = If([Record ID#] > 0, ToText([Record ID#]), "%%RID%%");
      var text URL = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & $RID;

      "<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #4b7097; border-radius: 5px; color: #ffffff; display: inline-block; padding: 0px 0px 0px 0px; width:100px; text-align: center; text-shadow: none; border: 2px solid #030404; font-size: 12px \"href='"
      & $URL
      & "'>Save and Display</a>"

      But this only works if the parent record was dirtied ( changed).  So you can make a field called [dummy date / time field to force save] and then use a form rule to set that to the current date time at all times.  That should dirty the record.

      when [dummy date / time field to force save] not equal to current date time ch age [dummy date / time field to force save] to current date time

      be sure to uncheck that checkbox so it fires all the time. ​

      Mark Shnier (Your Quickbase Coach)
      • ElenaLarrabee1's avatar
        Qrew Captain

        Hey Mark, is there an easy way you can think of to get this to close the window/redirect back to the parent after a save? I'm trying to redirect it to my close window code page without success. 

        Elena Larrabee