Forum Discussion

MikeKlausing's avatar
MikeKlausing
Qrew Assistant Captain
5 years ago

Save and next tab button

I used to have a save and next button that would move the user to the next tab on my form.  It no longer works and i've tried to look at the new posts about what changed but it still doesnt work.  Here is what I have done

SaveAndNextTab.js
var nextTabLink=$("li.ui-tabs-active").next("[style!='display:none']").children("a");
$("#saveAndKeepWorkingMenuOption").click();
$(nextTabLink).click();
location.assign('#navTop');

 customButtonScript1
<a href='javascript:($.getScript("https://xxxx.quickbase.com/db/bpgjc56je?a=dbpage&pagename>

customButtonScript2
"));void(0);


button: 

[customButtonScript1]
& "SaveAndNextTab.js"
& [customButtonScript2]
& "' class='Vibrant' style='color:white; background:#427cd8; white-space:nowrap;'>Next</a>"

------------------------------
Mike Klausing
------------------------------

11 Replies

  • Mike,

    I was able to adjust your provided code to make a working feature with a Rich Text field. Here's the working code:
    var text customButtonScriptOne = "<a href=javascript:$.getScript('https://YOURREALM.quickbase.com/db/YOURDBID?a=dbpage&pagename=";
    var text customButtonScriptTwo = "');void(0);";
    
    $customButtonScriptOne
    & "SaveAndNextTab.js"
    & $customButtonScriptTwo
    &  " class='Vibrant' style='color:white; background:#427cd8; white-space:nowrap;'>Next</a>"
    Note, I had to switch some of the " to ' and vice versa for this to work in Rich Text. Syntactically, yours would have worked in a .js page.

    I can't speak as to why your code stopped working, but I was able to identify a few potential syntax errors. Updating these allowed the feature to work in my app.
    • No "=" after "pagename" (Line 1)
    • Extra anchor element closing bracket (Line 1)
    • No need to surround "javascript...void(0);" with single quotes. This may have caused some wires to get crossed when it comes to " or '
    • Potentially redundant () surrounding "javascript...void(0)"

    By the way, this button is a really cool feature. Thanks for sharing it here.

    Thanks,
    ------------------------------
    Evan Westbrook
    PRIME Developer
    Harder Mechanical Contractors Inc.
    Portland OR
    ------------------------------
    • DonLarson's avatar
      DonLarson
      Qrew Commander
      Evan,

      Just to clarify,  you have the SaveAndNextTab.JS code saved as a page?

      Don

      ------------------------------
      Don Larson
      Paasporter
      Westlake OH
      ------------------------------
      • EvanWestbrook's avatar
        EvanWestbrook
        Qrew Cadet
        Don,

        Yes. SaveAndNextTab.js is a code page. I copy and pasted Mike's code for SaveAndNextTab.js directly.

        Thanks,

        ------------------------------
        Evan Westbrook
        PRIME Developer
        Harder Mechanical Contractors Inc.
        Portland OR
        ------------------------------
    • MikeKlausing's avatar
      MikeKlausing
      Qrew Assistant Captain
      Evan, 

      I have been unable to get this working still. I am still supposed to be using the .js page right?

      No matter how I am putting in that code you gave me it is giving me syntax errors.

      ------------------------------
      Mike Klausing
      ------------------------------
      • EvanWestbrook's avatar
        EvanWestbrook
        Qrew Cadet
        Mike,

        SaveAndNextTab.js is a code page. The rest of the code blurb is in a "Formula - Rich Text" field.

        Regarding debugging, try the following:

        • Make sure your field is "Formula - Rich Text."
          • In Rich Text, we're making a button using an anchor element instead of letting QuickBase do it for us through a URL field.
          • Your original syntax looks "Formula - URL"ish. That might result in a QuickBase syntax error.
        • Hover over the button in QuickBase and look at the bottom left corner of your browser window. This will give you a preview of the code that will execute on click
          • This is helpful verifying what QuickBase is actually making with the formula.
          • Make sure everything looks correct there. javascript execution in QuickBase is very strict when it comes to no spaces.
          • Correct Syntax Result
          • Incorrect Syntax Result (special character trimmed everything after "getScript(")
        • Open the developer tools of your browser (F12), access the Console, and watch it when you click the button. If there is a JavaScript error or something isn't working as expected, an error will often appear in the console log.
        If all else fails, could you attach a screenshot of the syntax error? Is it in the QuickBase field or the JavaScript page? I'm interested to see your solution. Maybe there's an App Setting I'm missing.

        Thanks,
        ------------------------------
        Evan Westbrook
        PRIME Developer
        Harder Mechanical Contractors Inc.
        Portland OR
        ------------------------------