Builds a version two field, which is a typed value an app contributes for use in segments, journeys and queries. Obtained from newFieldBuilder on the controller mappings. Give the field a return type, optionally the parent types it hangs off, and either an eval function or the name of a bean property to read. Call build to create and register it. Building is skipped once the app's engine has finished initialising, and an app is warned about, then blocked, as its field count passes 200 and 300.
Group: Builders
Methods
returnType(String s) · parentType(String s) · parentTypes(Object s) · parentTypes(Object s) · evalFunction(Object s) · appendQueryFunction(Object s) · evalProperty(String propertyName) · build() · build(List<Field> fields)
returnType(String s)
Returns: FieldV2Builder
Sets the type of value the field evaluates to.
| Parameter | Description |
|---|---|
s | one of datetime, string, integer, boolean or double, or the name of an object type such as Profile or Lead |
parentType(String s)
Returns: FieldV2Builder
Sets the single parent type this field hangs off, so the field is only offered when querying from that type.
| Parameter | Description |
|---|---|
s | name of the parent type, for example Profile |
parentTypes(Object s)
Returns: FieldV2Builder
Sets the parent types this field hangs off, accepting a single string, a list or an array, or null for a root level field.
| Parameter | Description |
|---|---|
s | the parent type names as a string, list or array, or null |
parentTypes(Object s)
Returns: FieldV2Builder
Sets the parent types this field hangs off, given as separate arguments.
| Parameter | Description |
|---|---|
s | the parent type names |
evalFunction(Object s)
Returns: FieldV2Builder
Sets the function used to evaluate the field's value for a given profile or parent object. May be a function name or an actual JavaScript function.
| Parameter | Description |
|---|---|
s | the evaluation function, or its name |
appendQueryFunction(Object s)
Returns: FieldV2Builder
Sets a function that translates a comparison on this field into an Elasticsearch query, making the field searchable rather than only evaluable. The function is called with the operator and value and should return a query, for example one built with services.queryManager.createDefaultQuery.
| Parameter | Description |
|---|---|
s | the query building function, or its name |
evalProperty(String propertyName)
Returns: FieldV2Builder
Reads the field's value from a bean property on the parent object instead of calling a function. Use it for values that are already exposed as a property.
| Parameter | Description |
|---|---|
propertyName | name of the property on the parent type to read |
build()
Returns: void
Builds the field and adds it to this app's statically configured field list. Does nothing once the app's engine has finished initialising.
build(List<Field> fields)
Returns: void
Builds the field and adds it to the given list, which lets fields be produced dynamically rather than at load time. The field is skipped if neither an eval function nor an eval property was set, and once the list already holds more than 300 fields.
| Parameter | Description |
|---|---|
fields | the list the built field is added to |