Skip to main content

Automation targets

An automation target is what an automation does: send an email, send a message to a queue, post to Teams, run a process, build a curve and so on. OpenDataDSL provides the common targets, extensions add their own (Validation adds Run validation checks, Composer Build composition), and your company can create its own, such as Northgate's Send to the Northgate ETRM.


The Targets tab​

The Targets tab lists every target you can use: OpenDataDSL's, your extensions', and your company's own. When your company has a target with the same id as an OpenDataDSL one, yours replaces it.

The Targets tab

ColumnWhat it shows
TargetThe target's name and id. Yours marks your company's own targets
DoesIts description, and the sentence its automations end with
Works withThe services whose items can trigger it (any, or a list) and the actions it can be used for (anything, or a list). Can transform means its automations can transform the data with a mustache script first, property change that they can fire only when a property has a value
SettingsWhat each automation of the target needs. Hover over a setting for its description. Fixed lists the settings the target sets for every automation
Used byHow many automations use the target

Select Automations to open the Automations tab filtered on the target, Extend to make a target of your own from it, and, on your own targets, Edit to change it.


How targets shape the New tab​

When you create an automation, the New tab only offers the targets whose Works with includes the item's service, and for each of them only the actions it works with. At Northgate, Send to the Northgate ETRM works with data updates only, so it is offered for a curve, but not for a process or a report.


Common targets​

TargetIdSettings
Send an emailodsl.emailto, subject
Send an email with an attachmentodsl.email_attachmentto, subject, attachmentName
Send a message to a queueodsl.queuequeue
Send a Teams messageodsl.teamsurl, template
Send a webhook messageodsl.webhookurl, template
Run a processodsl.processprocess

The settings of every OpenDataDSL target, with examples, are described in Automation targets. The Targets tab always shows the targets and settings available to you.


Your own targets​

Your company can make its own targets in two ways:

WayUse it toExample
Extend a targetFill in some settings of an existing target for everyone, so users only fill in the restSend a Teams message, with the Market Data channel's address already filled in
Run your own scriptDo anything an ODSL script can, with settings users fill in on each automationIncrement a counter field on a master data record

Your targets are private: only your company sees and uses them. They are offered on the New tab like any other target. Their id is publisher.code, and a target with the same id as an OpenDataDSL one replaces it for your company, for every automation that uses it.


Extending a target​

Northgate's market data team posts to the same Teams channel from many automations. Rather than paste the channel's webhook address into every one, Priya makes a target with it filled in.

  1. On the Targets tab, select Extend on Send a Teams message.
  2. Fill in the target's details (see the field table below): publisher northgate, code teams_market_data, name Tell the market data channel.
  3. In Settings, enter the channel's webhook address as the Fixed value of url. A fixed setting is set for every automation of the target, and users are not asked for it.
  4. The sentence still contains [url], which users would now see unfilled, so the form warns about it. Select Write the fixed values in, then reword the sentence: send a Teams message to the Market Data channel using [template]. The preview shows how it reads on the New tab.
  5. Select Create target.

Extending Send a Teams message with the channel's address filled in

The new target runs the same built-in handler as the one it extends, with your fixed settings. Users now pick Tell the market data channel on the New tab and only choose the message template.

note

A setting the original target already fixes (such as attachment on Send an email) is copied with it. Change it only if you know what the handler does with it.


Running your own script​

A script target runs one of your ODSL scripts each time an automation fires. Inside the script:

VariableWhat it holds
#PROPERTIESThe settings: those users filled in on the automation and the target's fixed ones, plus id (the item), ondate (for curves) and range (for timeseries), which the platform always adds
#OUTPUTThe data that triggered the automation (the item as it was saved)
#LOGThe run's log entry. Its status comes from the script: the run fails when the script fails (for example with fail "the record was not found") and succeeds otherwise

This script increments a counter field on a master data record. Its first comment puts it in the category automation-target, which is what makes it appear in the list of scripts when you make a target:

/** Increments a counter field on a master data record @category automation-target */
print "Running custom target"

oid = #PROPERTIES.objectid
counterfield = #PROPERTIES.counter

// Increment a counter
bulk update ${object} where _id=oid
inc(counterfield=1)
end

Save it as a private script, here automations\increment-counter, then make the target:

  1. On the Targets tab, select New script target.
  2. Fill in the details: publisher northgate, code inc_counter, name Increment a counter, icon node-plus.
  3. Choose the script in ODSL script (start typing to see your automation target scripts) and select Read the script. Every #PROPERTIES.name the script uses is added as a setting, here objectid and counter. Describe each one: users see the description when they fill it in.
  4. Write the sentence, with each setting users fill in as [name]: increment counter [counter] in record [objectid].
  5. Under Works with, untick Any action and tick is updated, and untick Can transform the data first: the script does not use the data.
  6. Select Create target.

A script target that increments a counter

The target saved by the form:

{
"_id": "northgate.inc_counter",
"publisher": "northgate",
"code": "inc_counter",
"name": "Increment a counter",
"description": "Increment a counter in a master data record",
"icon": "node-plus",
"script": "automations\\increment-counter",
"template": "increment counter [counter] in record [objectid]",
"tags": ["Custom"],
"inputs": {
"objectid": {"description": "The id of the record to update"},
"counter": {"description": "The name of the field to increment"}
},
"properties": {},
"services": ["*"],
"actions": ["update"],
"allowTransformation": false,
"allowPropertyChange": true
}
note

The platform sets an ODSL script's description and category from its first comment each time it is saved: the text is the description, and @category name (one word) the category. A script without @category automation-target in its first comment is not listed.

tip

Open a new automation that uses the target and select Run now to try it. Its status and message are on the Activity tab.


The target form​

FieldWhat it is
Publisher and CodeTogether the target's id, publisher.code. Letters, numbers, - and _. The publisher defaults to your company's. They cannot be changed once the target exists
Name, DescriptionWhat users see when they choose a target
IconA Bootstrap icon name, such as microsoft-teams or node-plus
TagsWords to group targets by, comma separated
Built-in handler or ODSL scriptWhat runs. An extended target keeps the handler or script of the one it extends; a script target runs the script you choose. The list offers your ODSL scripts in the category automation-target (private, and public ones starting with #); you can type another id, and the form warns that it is not an automation target script
SettingsOne row per setting: its name, description and type (text, yes or no, a mustache script, or a list of choices). Leave Fixed value empty for a setting users fill in; fill it in to set it for everyone. id, ondate and range cannot be used: the platform sets them
SentenceHow automations of the target end, such as send a message to [queue]. Each setting users fill in goes in as [name]; a setting that is not in the sentence is optional
Works withThe services whose items can trigger it and the actions it is offered for. Can transform the data first offers the transformed sentences (a mustache script turns the data into another format first); Can fire only when a property has a value offers the property change and property set sentences

The form checks the details as you type: a [name] in the sentence that is not a setting, a fixed setting still in the sentence, or a setting users fill in that the sentence leaves out.


Changing and deleting your targets​

Select Edit on one of your targets to change it, then Save. The change applies to every automation that uses the target from its next run.

To delete a target, select Delete in the form. The confirmation says how many automations use it. Those automations fail every time they run until you create the target again or delete them, unless your target replaced an OpenDataDSL one with the same id: they then use that one again.

OpenDataDSL's and your extensions' targets cannot be changed here; extend them instead. See also Custom targets.


Next​