Skip to main content
Error Showing Content - please login as admin for details.
Error Showing Content - please login as admin for details.

Formulas Tutorials

Tutorial Home

Formulas affecting Groups of Fields

We'll show you examples where formulas can be applied to change visibility, collpased, Help Text and more.

Important: The feature "Public Use of Edit Form" is disabled

The feature is needed for anonymous users to use the Edit Form. Register your site here https://patrons.2sxc.org/ to get access to the feature.

Group visibility

    This formula determines the visibility of the Advanced settings group. The group becomes visible, when the Advanced toggle is active.
    Click on the (Σ) button above to see the edit-UI with the formula.

    Formulas of FormulasVisibleGroup.AdvancedSettings

    Field.Settings.Visible (Formula-Target: Field.Settings.Visible)

    function v1 (data, context) {
      return data.Advanced == true;
    }

    Group Name - Text summary

      This formula changes the Name of the PersonGroup field. The name becomes "Person - Profile complete" if all group fields are filled out and "Person - Profile incomplete" if not.
      Click on the (Σ) button above to see the edit-UI with the formula.

      Formulas of FormulasTextSummary.PersonGroup

      Field.Settings.Name (Formula-Target: Field.Settings.Name)

      function v1 (data, context) {
        if (data.Firstname != "" && data.Lastname != "" && data.Address != "")
          return "Person - Profile complete";
        return "Person - Profile incomplete"
      }

      Group Name - Emoji summary

        This formula changes the Name of the ProductGroup field. The name becomes "Product ✅" if all group fields are filled out and "Product ✏️" if not.
        Click on the (Σ) button above to see the edit-UI with the formula.

        Formulas of FormulasEmojiSummary.ProductGroup

        Field.Settings.Name (Formula-Target: Field.Settings.Name)

        function v1 (data, context) {
          if (data.Name != "" && data.Pricing != null) {
            return "Product ✅";
          }
          return "Product ✏️";
        }

        Helptext

          This formula adds a help text based on the ProductCode Field text. If the ProductCode field contains "n0t0k" the helptext "This product code is deprecated. Please request a new product code. " is added, or if it contains spaces the helptext "Please remove all spaces from your product code." is added.
          Click on the (Σ) button above to see the edit-UI with the formula.

          Formulas of FormulasHelpText.ProductCode

          Setting Notes (Formula-Target: Field.Settings.Notes)

          function v1 (data, context) {
            const isDeprecated = data.ProductCode.includes("n0t0k");
            const hasSpaces = data.ProductCode.includes(" ");
            
            return (isDeprecated ? "This product code is deprecated. Please request a new product code. " : "") 
            + (hasSpaces ? "Please remove all spaces from your product code." : "");
          }

          Run Code Only when Form Opens

            This formula determines the initial open/closed state - in this case randomly. Normally it would do this based on how complete data in that section is or based on other criterias. This is often used to improve initial state of a form based on how much data is already filled in.
            Click on the (Σ) button above to see the edit-UI with the formula.

            Formulas of FormulasRunAtStart.GroupRandomlyOpen

            Field.Settings.Collapsed (Formula-Target: Field.Settings.Collapsed)

            function v1 (data, context) {
              // On second+ runs, leave value as is
              if (context.cache.alreadyRun) return data.value;
              context.cache.alreadyRun = true;
            
              // Get random true/false
              var random = Math.random() < 0.5;
              return random;
            }