Defining expressions
One of the key strengths of Altogic is its flexibility to define expressions, which are used to set default values and define validation rules of fields and customize parameters of service nodes.
It is quite easy to define an expression; whenever you see the f(x) button, click/tap on it.
Clicking/tapping on f(x) will launch the expression editor, where you will be able to access object values and built-in functions. The key components of the expression editor include:
Expression editor key components
  1. 1.
    Model objects - Each expression editor can have a different number of model objects as input. When setting the default value of a field or adding a new validation rule to a field, you have just one model object as input which is the model of the field. On the other hand, when customizing a parameter of a service node, the service node might have multiple input link points. For each input link point (excluding trigger link points), you will have a corresponding model object entry in the expression editor. In the above example, we have two model objects that can be used when defining the expression named "user" and "product." When you click/tap on them, the contents area is updated with the right model fields structure.
  2. 2.
    Service parameters - Particularly available for expressions defined in service designs, you can access all the input parameters provided by the start node of the service using this tab. It basically provides quick access to service input parameters.
  3. 3.
    Functions - Through the functions tab, you can use built-in functions in your expressions. Please refer to the functions reference for more details on each built-in function.
  4. 4.
    Contents - This is the main area of the expression editor where contents of each selected tab (e.g., model object, service parameters, functions) are displayed. You can either double click on a value or drag & drop it to the edit area to use it in your expressions.
  5. 5.
    Edit area - The text editor where you build your expression.

Using expressions in text editors

You can also use expressions when editing plain text or HTML documents. Using the text editor, you can write your text or HTML content as it is and insert expressions whose values will be evaluated and injected into your text or HTML content using the mustache operator {{ mustache }}. This is particularly useful in defining plain text or HTML email message bodies.
In the below example, we use the text editor to create the email body for a sign-up process to send a validation code to the user's email address. During the execution of this service, Altogic evaluates the values for the expression specified between the mustache operator {{ mustache }} and replaces them with the evaluated values.
Using expressiosn in text editors example

Using expression in JSON editors

Similar to using an expression in text editors, you can also use expressions when editing JSON documents. Using the JSON editor, you can write your JSON document as it is and insert expressions whose values will be evaluated and injected into your JSON document using the mustache operator {{ mustache }}. This is particularly useful in defining RESTFul API request bodies for 3rd party APIs.
In the example below, we define a new custom node called 'Send Transactional Email' to send email messages using SendGrid services. SendGrid's transactional email API requires a JSON document in the request body. Below we provide all required request body input parameters of the SendGrid API using the JSON editor and expressions.
Usind expressions in JSON editors example