Builds a funnel trigger type, which lets an automation be started by an event raised by this app. Obtained from addFunnelTriggerType on the controller mappings. Set the description, the parameter fields an administrator fills in when configuring the trigger, and optionally a match function that decides whether a given event matches those parameters. Call build to register the trigger type; registration is ignored once the app's engine has finished initialising.
Group: Builders
Methods
description(String s)
Returns: FunnelTriggerTypeBuilder
Sets the description shown to administrators alongside the trigger name when they pick a trigger for an automation.
| Parameter | Description |
|---|---|
s | the description text |
itemIdField(String itemIdField)
Returns: FunnelTriggerTypeBuilder
Names the event parameter that holds the identifier of the item the event is about. The automation reads that parameter from each event to work out which item the trigger fired for, which is what allows per item de-duplication.
| Parameter | Description |
|---|---|
itemIdField | name of the event parameter holding the item identifier |
checkMatchFn(String functionName)
Returns: FunnelTriggerTypeBuilder
Names the function to call when checking whether a trigger event is matched by the parameters configured on the automation trigger, for example function checkMatch(event, triggerParams). If no function is given every event of the right type matches, and if the function throws the event is treated as not matching.
| Parameter | Description |
|---|---|
functionName | name of the global JavaScript function that checks the match |
fieldsFunction(String functionName)
Returns: FunnelTriggerTypeBuilder
Names a function that adds configuration fields to the trigger dynamically, called with the field list each time the fields are needed. Use it when the available options depend on account data rather than being fixed at load time.
| Parameter | Description |
|---|---|
functionName | name of the global JavaScript function that populates the field list |
addField(String name, String options)
Returns: FunnelTriggerTypeBuilder
Adds a configuration field to the trigger from a short field definition string, parsed the same way as other app extra fields.
| Parameter | Description |
|---|---|
name | name of the field, which is also the parameter key it is stored under |
options | field definition string giving the type and any options |
addField(String name, String text, boolean required, List<String> options)
Returns: FunnelTriggerTypeBuilder
Adds a configuration field to the trigger with an explicit label and a fixed list of select options.
| Parameter | Description |
|---|---|
name | name of the field, which is also the parameter key it is stored under |
text | label shown next to the field |
required | true if the administrator must supply a value |
options | the values offered in the field's drop down |
addFieldWithOptionsFn(String name, String text, boolean required, Supplier optionsFn)
Returns: FunnelTriggerTypeBuilder
Adds a configuration field whose select options are produced by a supplier function that is called when the field is rendered, so the options can reflect current account data.
| Parameter | Description |
|---|---|
name | name of the field, which is also the parameter key it is stored under |
text | label shown next to the field |
required | true if the administrator must supply a value |
optionsFn | supplier called to produce the list of options |
build()
Returns: void
Creates the funnel trigger type from the configured values and adds it to the trigger type list this builder was created for. Does nothing if the app's engine has already finished initialising.