Introduction

Getting started

Walkthrough Guides

CafeX Apps

Workflows

Using CafeX Collaborate App

Reporting

Managing CafeX

Integrating CafeX

Security

App Studio

App Studio Components

CafeX Apps

Understanding mustaches and expressions

Modified on Tue, 14 Jan at 8:38 AM

TABLE OF CONTENTS

Introduction to Mustaches and Expressions

As an App Builder in App Studio, you use expressions to combine values and operators to derive new results. These expressions often involve simple mathematical operations. Some expressions produce constant values that remain unchanged, while others derive dynamic values from one or more data sets. Additionally, you use mustaches ({{ }}) to reference data set values or component properties that may change as users interact with your App. Think of mustaches as dynamic placeholders or variables in mathematical operations, enabling your App to present dynamic information. For instance, an expression can toggle the visibility of a component when a user clicks a button.


App Studio supports the use of mustaches in many areas, allowing you to pass dynamic values for evaluation and create responsive, interactive apps. Moreover, wherever mustaches are supported, expressions can also be used.


Where to Use Mustaches and Expressions

You can enter mustaches and formulas in various parts of App Studio.

To set the visibility of a ComponentAppearance > Visible field
To display a value in a Text ComponentConfiguration > Text
To set the default value of a Form fieldConfiguration > Field > Default value
To assign a value to a VariableApp > Configuration > Data set > Variable  > Expression
To define a value for an EventConfiguration > Event handler > Set a variable > Value to set
To set a value for a Validation Rule in a Form ComponentConfiguration > Form validation > Custom expression ('fx' icon next to the Condition field)


Creating Mustaches

To create a mustache expression, follow these steps:

  1. Enter a mustache in a supported area. Type {{to begin.
    {{
  2. As you open the braces, a list of available Data Sets and Components appears to help you complete the reference. For example,
    {{buttonVariable}}
    https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/73070257669/original/81KGDqikpkmtsJ8rp85L7-_OD3y__hEkcg.png?1693832138 
  3. To tag a specific field of a Data Set:
    1. After typing the mustache, type .  to access fields within the object.
    2. The set of fields appears and you can tag them, for example:
      {{object.field}}
  4. To tag an element of an array or list, use the index of the element to reference it, for example:
    {{object.array.0}}

Important: When referencing a value with a mustache, your App automatically escapes special characters. To include raw content without escaping, use three braces ({{{ }}}) instead of two ({{ }}). 


For example,


Field ValueMustacheOutput
A&B{{Variable}}A&B
A&B{{{Variable}}}A&B


Creating Expressions

Expressions allow your App to evaluate values dynamically using operators and variables, updating automatically whenever the referenced values change. 


Key considerations for expressions:

  • An expression must include at least one mustache ({{ }}) to be evaluated. Otherwise, your App might treat the expression as plain text. 
  • The evaluation depends on the data type of the mustache. Use appropriate values such as true, false, or numbers to ensure proper results.


Logical Operators in Expressions

The following table includes some basic examples of formulas that use logical operators to evaluate as either true or false. Typically, you use these to set the visibility of a Component.


OperatorsExample
NOT!{{variable}}
AND{{variable1}} && {{variable2}}
OR{{variable1}} || {{variable2}}
EQUALS{{variable}} == value
NOT EQUALS{{variable}} != value
GREATER THAN{{variable}} > 100
GREATER THAN OR EQUALS{{variable}} >= 100
LESS THAN{{variable}} < 100
LESS THAN OR EQUALS{{variable}} > 100
Expressions( {{A}} && {{B}} ) || {{C}}



Mathematical Operators in Expressions

The following mathematical operators are available to use with numbers:


OperatorsExample
ADDITION{{VAR}} + {{VAR}}
SUBTRACTION{{VAR}} - {{VAR}}
MULTIPLICATION{{VAR}} * {{VAR}}
DIVISION{{VAR}} / {{VAR}}
EXPONENT{{VAR}} ^ {{VAR}}
Ternary operator({{VAR}} >= 100) ? "Greater Than or Equal" : "Less Than"

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article