Last updated
Last updated
Dynamic form items allows you to create form items dynamically through the onLoad script in the activity template's settings.
This is a highly advanced concept and is still being improved. If you're not familiar with TilliT DO just yet, create your activity items throught the UI.
Create an activity template. See .
Then click on Edit Template, expand the Scripts drawer.
Click on the Calculator icon to the right of the Onload Script's input field. When a modal appears, this is where we will be putting in our JSON-based script. JSON, or JavaScript Object Notation, is a widely used format for storing and exchanging data. It’s both human-readable and machine-parsable.
Let’s break down these examples into simple, easy-to-understand terms. Even if you're not familiar with coding or JSON, think of this as filling out a form, where each part defines what the form will look like and how it will behave.
Here’s an example script that adds two form items:
A number input (Field 1, not required)
A text input (Field 2, required)
Field 1:
Label: "Field 1."
Hint: A hint to the users.
Type: Accepts numbers only.
Active: It’s visible to users.
Field 2:
Label: "Field 2."
Type: Accepts text only (e.g., letters, words).
Active: It’s visible to users.
Required: Users must fill this field before submitting the form.
Click Save to close the modal and Save again to apply your changes.
The form will now include the items you just configured, these items' properties aren't editable through the UI but must be changed through the onLoad script that we just wrote.
Now feel free to use the references tables below to help you write your scripts, with examples included at the end.
The references tables' purposes is to help you understand how different fields and properties are structured and what kinds of information they accept. Each table provides essential details about the properties, their data types, and any associated custom types or options. Here's how to read and use it effectively:
Each table has the following columns:
Property Name: The name of the property used in the system. Think of it as a label or identifier for a specific part of the form or data.
Property: A simplified version of the property name, often the one you'd see or reference in usage.
Data Type: The kind of information this property accepts. For example:
STRING
: Text-based information like words or phrases.
NUMBER
: Numeric values.
Custom data types (e.g., TREE
, SINGLE
): Specific categories or types explained in another table.
This table explains the properties of an Option Group, a part of the form that lets users make selections:
name
Property:
Data Type: STRING
This means the property accepts text, such as "Preferred Colors" or "Favorite Fruit."
type
Property:
Data Type: Reference to Table 6.
You must select a predefined type from the Option Group Types table, which lists the available categories for this property.
Some properties use custome data types, which are predefined values that you must choose from. For instance, the type
property in Table 5 refers to these Option Group Types:
How to Use Custom Enums:
Match the description to your use case.
Use the custom data types (e.g., SINGLE
or MULTIPLE
and not String, Text or Number) in your configuration.
When a property references another table (like how type
in Table 5 points to Table 6), it means the value for that property must come from the options in the referenced table. This ensures consistency and clarity in how the data is defined and used.
Identify Required Properties: Look at the Property Name and Property columns to see what information you need to provide.
Match Data Types:
Make sure the values you provide match the required data type (e.g., text for STRING
, numbers for NUMBER
, or specific date types for custom types).
Follow References: If a property points to another table, review the referenced table to understand what values are valid.
Use Descriptions for Context:
The descriptions in the custom enums (like Tree Type
or Downtime reason
) help you decide which value fits your scenario.
Don't forget $formItems.push():
Don't forget to add $formItems.push(insert your form items here)
in order to actually add the items dynamically through the script.
See to learn more.
See
See for more information.
See for more.