Forum Discussion

Team_Kinnect's avatar
Team_Kinnect
Qrew Trainee
2 months ago

Including two classes in one button

I'm working with a rich text button. The button is on a parent record. The user clicks the button, the parent is saved, and then a popup opens to add a child record. When I add the savebeforenavigating class, the button stops opening the window in a popup and instead opens in a new tab.

Is it possible to include both classes in the same formula?

var number rid = [Record ID#];var text url = 
URLRoot() & "db/" & [_DBID_CHILDREN] & "?a=nwr" & "&_fid_10=" & URLEncode($rid) & "&ifv=1" & "&hs=1";
var text color = "#228B22";
var text txtcolor = "White";

"<a class='SaveBeforeNavigating' & \"OpenAsPopup\" data-height=\"800\" data-width=\"1000\" data-refresh=\"true\" " &
 "style=\"text-decoration: none; text-align: center; background:" & $color & "; color: " & $txtcolor & "; border-radius: 5px; margin: 2px; padding: 5px 5px; width: 100px; display: inline-block; font: 14px/ 'Calibri', 'Segoe UI', sans-serif; text-shadow: none;\"href='" & $url & "'>Add Child</a>"

6 Replies

  • I think I need something like this as well. Anyone know if this is possible? My use case is that I have a Save and Refresh button on a form that is primarily interacted with as a popup subform. When I use the Save and Refresh button it saves, refreshes but now my popup subform is now a full windowed form. Looking for a way to save and refresh and retain popup subform display.

  • Denin's avatar
    Denin
    Qrew Trainee

    The classes are CSS classes. In that sense, you can put as many as you want. Try it out like this to see if it works as intended:

    "<a class='SaveBeforeNavigating OpenAsPopup' data-height=\"800\" data-width=\"1000\" data-refresh=\"true\" " &
     "style=\"text-decoration: none; text-align: center; background:" & $color & "; color: " & $txtcolor & "; border-radius: 5px; margin: 2px; padding: 5px 5px; width: 100px; display: inline-block; font: 14px/ 'Calibri', 'Segoe UI', sans-serif; text-shadow: none;\"href='" & $url & "'>Add Child</a>"

    If it doesn't work, then it's an incompatibility with the script QuickBases uses.

  • Guess it is a QuickBase script issue as I get the following after updating the code and using the button.

    Bummer.

    • Denin's avatar
      Denin
      Qrew Trainee

      In that error it looks like the URL did not receive the record ID. I'm not sure the issue is the same, maybe post your complete formula.

  • var text rid = 
        If([CID]>0,
            ToText([CID]), // Record ID already exists
            "%%rid%%" // New record, no Record ID exists yet
        )
    ;
    var text url = URLRoot() & "db/" & Dbid() & "?a=er&rid=" & $rid;

    "<a class='Vibrant Primary SaveBeforeNavigating OpenAsPopup' data-replaceRid=true href='" & $url & "'>Save & Refresh Pricing</a>"

    • hueyal's avatar
      hueyal
      Qrew Trainee

      It appears you cannot use SaveBeforeNavigating and OpenAsPopup together (in Formula Rich Text field). I'm not sure if using both is the cause of the error; however, both most likely would not be applied.

      See:  https://helpv2.quickbase.com/hc/en-us/articles/4570366896532-Configure-URL-Fields

      It states:

      Features when working with formula-rich text fields

      The features and capabilities include:

      • When you open a formula url as a pop-up, you can set a website to open in a popup window or a new tab. You can use this same functionality with formula-rich text by applying the CSS class (OpenAsPopup).
      • Use the CSS class (SaveBeforeNavigating) inside of a formula-rich text field and Quickbase will save the record before navigating.
        Note: Only one of these workflow classes is supported per formula-rich text.