Custom Javascript Logic
Custom JavaScript Logic allows you to create a derived field with a custom JavaScript logic or formula. To use this feature, you must have some knowledge of JavaScript.
How to Create a Derived Field with Custom JavaScript Logic?
1. Go to Derived Field
Open the settings of the collection in which you want to add a derived field with Custom JavaScript Logic. Then, click on Derived Fields in the tab.
2. Name the Derived Field
After opening the derived fields tab, adding the name of the derived field is the foremost step. So, type a name of your choice and then proceed to the next step.
3. Select the Method Type
The option of Method Type contains all the permutations you can use to create a derived field. Select Custom JavaScript Logic as the method type.
4. Add the Custom JavaScript Logic
Type your Custom JavaScript logic and click the Create button. In the example below, a logic to segregate data between minor and adult on the basis of age is created.
5. Bind the Collection to a CMS Component
Open a page and drop a CMS component in it. Then bind the collection in which you had previously create a derived field to the component.
In the example below, the collection is bound to a data table.
6. Duplicate a Field
If you are using a data table, then duplicate a field so it could be turned into a derived field. To duplicate a field, open the settings of the field you want to duplicate and click on the duplicate icon as shown below.
7. Bind the Derived Field
After duplicating a field, open its settings and click on Select Column Field option. A drop-down list containing all field names will appear. Select the Custom JavaScript Logic derived field.
8. Publish or Preview
Open the page in the publish or preview mode. You will see that the derived field with Custom JavaScript logic is showing result after running the logic on the data.