1. Help Center
  2. Function Fields

How to configure Function Fields

Learn to configure Function Fields so that you can customize and automate your workflows and datasets further.

Function Field is an option that you can enable for most field types (e.g. text, date, and numeric). The value of the field is computed by Hailer automatically, rather than edited by you manually. If you are new to Function Fields, you can find the introduction here.

 

Function Fields are available for Enterprise licenses. Contact us for more information at info@hailer.com

 

Please note that configuring Function Fields requires at least a basic knowledge of programming and familiarity with the JavaScript programming language.

Opening the Function Fields Editor

Function Fields Editor is the place where you configure your Function Fields. You can open the editor in two ways. Either by clicking the "Edit Function" button in the"Fields" tab in the workflow settings:

 

how_to_ff_open_fields

Or by clicking the function icon ("f") in the side navigation of an activity:

 

how_to_ff_open_sidenav_v2

 

Function Fields Editor

Let's now get familiar with the different sections of the Function Fields Editor. 

 

how_to_ff_editor_top

how_to_ff_editor_bottom_v2

1. Field

Lists out the label of the Function Field ("VAT") and additional information about the field. In this case the type of the field ("numericunit") and its unit ("€").

2. Function

Environment for typing in with JavaScript a set of rules, a function, for returning a certain value.

3. Run Function

Click to run the function. You may need to do this to reveal the remaining sections of the editor.

4. Light / Dark

Shows the current theme of the editor ("Light" or "Dark"). Click to change the theme. Changing the theme will change the background color and font color of the function editor. Click "Save Changes" and re-open the Function Fields Editor to see the change.

5. Output

Shows the computed value of the field based on the function ("240 €"). 

6. Activity

The name of the activity that the data in the Output and Evaluation Context are based on ("Rau Inc - Services").

7. Evaluation Context

Lists out all the data that is available to the function.

8. Cancel

Click to cancel any changes you have made. Closes the Function Fields Editor.

9. Save Changes

Click to save the changes you have made. Closes the Function Fields Editor.

Evaluation Context

Let's take a deeper look at the evaluation context. It consists of a collection of objects that allow the function to access values from the current and linked activities. With linked activities, linking works in two ways: an activity either links to another activity or another activity links to it (read more about linked activities). The objects are:

  • row
  • row.$
  • row.$.linkedFrom
  • row.$.linkedFrom[i].fields
  • row.$['enter field name here'].fields

row

Contains all fields of the current activity. 

row.$

Contains the activity name, metadata, and data from linked activities.  

row.$.linkedFrom

Contains data from linked activities.

row.$.linkedFrom[i].fields

Contains the fields of an activity that is linked to the current activity.

 

Use underscore ("_") to access fields that have names with multiple words in them.

row['enter field name here'].fields

Contains the fields of an activity that has been selected in an activity link field.

 

Use space (" ") to access fields that have names with multiple words in them.

Accessing Data Within the Evaluation Context

Let's say that you have a workflow for tracking orders for your products and services. You want to make it easier to calculate the VAT and total price for each order. You are okay with adding the price and VAT Rate for each order yourself but the rest should happen automatically. 

 

how_to_ff_ready

 

Your workflow needs the following fields:

  • "Order"
  • "Price"
  • "VAT Rate"
  • "VAT" 
  • "Price (incl VAT)"

 

how_to_ff_fields

 

The evaluation context is identical for the "VAT" and "Price (incl. VAT)" Function Fields. To calculate the VAT and total price of each order automatically, you need to write a function that accesses the row object. It contains the values of the "Price" and "VAT Rate" fields of the current activity.  

 

how_to_ff_evaluation_context

Write the following function to calculate the value for your "VAT" field automatically. Notice how the values of the "Price" and "VAT Rate" fields are accessed within the row object.

 

how_to_ff_function_vat_amount

 

Write the following function to calculate the value for your "Price (incl. VAT)" field automatically.

 

how_to_ff_function_total_price

 

You have now learned the basics of configuring Function Fields. If you wish to see a more advanced example, learn how to build a price calculator in Hailer.

 

Function Fields are available for Enterprise licenses. Contact us for more information at info@hailer.com