Skip to main content
Home  › ... Razor

Formulas Tutorials

Tutorial HomeFormulas

Advanced Formula APIs

In this tutorial you'll learn some of the advanced APIs such as:

  • Detect if features are enabled new in v14
  • Get user information about the current user new in v16

Important: Now using Formulas V2 🆕 in 2sxc 16

Formulas V2 has intellisense, stoppability, support for promises and more.

Try it:

    Show a warning or info based on the feature GoogleTranslate being enabled. 


    Click on the (Σ) button above to see the edit-UI with the formula.

    Formulas of FormulasFeatures.GoogleTranslateWarning

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

    v2((data, context) => {
      return !context.features.isEnabled("EditUiTranslateWithGoogle");
    });

    Formulas of FormulasFeatures.GoogleTranslateInfo

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

    v2((data, context) => {
      return context.features.isEnabled("EditUiTranslateWithGoogle");
    });

    Try it:

      This formula shows information about the user and shows a warning if the user is not logged in.


      Click on the (Σ) button above to see the edit-UI with the formula.

      Formulas of FormulasUser.UserInformation

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

      v2((data, context) => {
        return data.default
          .replace('[name]', context.user.name ?? "unknown")
          .replace('[userid]', context.user.id)
          .replace('[isanonymous]', context.user.isAnonymous)
          .replace('[issiteadmin]', context.user.isSiteAdmin);
      });

      Formulas of FormulasUser.WarningAnonymous

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

      v2((data, context) => {
        return context.user.isAnonymous;
      });