Forum Discussion

AlexWilkinson's avatar
AlexWilkinson
Qrew Assistant Captain
7 years ago

Custom buttons for tabbed forms: Save & Next Tab, Save & Same Tab

Here's a method to do variants of "Save & keep working" within a tabbed form. First, I'll explain how to create a "Save & next tab" button. Then, with slight modification, I'll show "Save & same tab".

[1] On the form properties, do not check "Show Save & close and Cancel buttons at the end of this form" and do check "Show save & keep working choice"

[2] Create a rich-text-formula field called, say, "Custom Save and Next Tab". Temporarily, you can fill it the text "Save & next tab". Eventually, after completing the steps below, it will contain a custom Page and several custom Variables, like this:

[customButtonScript1]
& "saveAndNextTab.js"
& [customButtonScript2]
& [customButtonStyleSKW]
& "Save & next tab"
& [customButtonEnd]

[3] In the settings for you app, click on Variables and add one called "customButtonScript1". You can use a different name, if you wish, but be sure to use that name in the first like of the rich-text-formula in step [2]. Whatever you call it, the variable should contains the following. The quotes are important. However, remove the spaces in h t t p s, use your company's setting for "yourdomain" and your app's id instead of "yyy999zzz"

<a href='javascript:($.getScript("h t t p s://yourdomain.quickbase.com/db/yyy999zzz?a=dbpage&pagename=

[4] Next, in the settings for you app, add a Page called "saveAndNextTab.js" (or another name you prefer, provided you use it in the second line of the rich-text-formula field"). The page should contains exactly this:

var nextTabLink=$("li.ui-tabs-selected").next("[style!='display:none']").children("a");
$("#saveAndKeepWorkingMenuOption").click();
var noErrorDialog=$('#qbDialog').length==0;
if( noErrorDialog ){
$(nextTabLink).click();
location.assign('#navTop');
};

In words, this script is (a) finding the currently selected tab, then the next that is not hidden, and it's name; then (b) clicking the standard "Save & keep working" button, emulating a user; and (c) checking for a pop-up error message, e.g., about failing to supply a required field; and finally (d) clicking the next non-hidden tab-name and scrolling up to where the tab-row will be visible.

[5] Back on your app's settings, add another Variable to close the script. Call it "customButtonScript2" if you are sticking to the naming in step [2]. It must contain exactly this:

"));void(0);

[6] Next you need to style the custom button. I prefer doing so as follow, to make it resemble the standard save buttons. Add another Variable in you app's settings called "customButtonStyleSKW" which contains this:

' class='Vibrant Tall' style='font-size:14px; color:white; background:#6BBD57; white-space:nowrap;'>

[7] Finally, in add one more Variable in your app's settings, called "customButtonEnd", containing simply:

</a>

Of course, you could just use "</a>" as the final line of your rich-text-formula field, but I prefer the additional Variable for readability ... and just in case I ever want to make some sort of global change for all my custom button's endings.

[8] Oh, and to get this button on your forms, add it at the end of every tab. (On the last tab, it will stay there, after not finding any next tab.) Naturally, you will want to use an empty "alternate label" for that row of the form, and set it for add and edit modes only.

To modify this method for "Save & same tab", the main change is in the first line of the script in step [4]. Use this:

var sameTabLink=$("li.ui-tabs-selected").children("a");

Also, later in the script, use:

$(sameTabLink).click();






  • this works great.  but i am stuck because of a variation in my tabs.  i have a tab that only shows based on a dynamic rule.  it is the second tab.  however, if it is not showing and i click the save and next tab on the first tab section it just stays on the first tab section instead of going to the 3rd (again because the rule hid the 2nd tab).  is there a trick to fix this?
    • BradLemke's avatar
      BradLemke
      Qrew Assistant Captain
      Several steps would be taken:

      First: Find out the tab number of the 3rd tab.  (using Chrome) While in the form, right-click on the tab you want it to go to and click 'inspect'. This will open a menu on the side that will show you the tab's actual number.

      Next: add a modified.JS page with the following code (striking out original code, bolding new code): 
      var nextTabLink=$("li.ui-tabs-selected").next("[style!='display:none']").children("a");
      $("#saveAndKeepWorkingMenuOption").click();
      var noErrorDialog=$('#qbDialog').length==0;
      if( noErrorDialog ){
      $(nextTabLink).click();
      $("#tab_t2_link a").click();
      location.assign('#navTop');
      };

      Be sure to change the t2 to the tab number you found earlier.

      Last, modify your custom button code with an if-statement:

      If(*conditions for rule show 2nd tab*, 
       [customButtonScript1]
       & "saveAndNextTab.js"
       & [customButtonScript2]
       & [customButtonStyleSKW]
       & "Save & next tab"
       & [customButtonEnd],
       [customButtonScript1]
       & "Modified.js"
       & [customButtonScript2]
       & [customButtonStyleSKW]
       & "Save & next tab"
       & [customButtonEnd]
      )
  • Hey @Alex Wilkinson,

    I'm trying to do something similar by using pieces of the code you created above but have not successfully gotten it to work.

    I created a separate post to the community. Would you mind taking a look to see if you know where I'm going wrong?

    I think I'm not doing something right when assigning the tab to the navtop.

    Quick Base Community Post: Opening Form to Specific Tab

    ​​​

    ------------------------------
    Hannah Wright
    ------------------------------