Skip to main content

Script Target

The script target runs an ODSL script whenever an automation fires. It is the most flexible built-in target: any logic you can write in ODSL can run in response to a platform event.

IdNameTemplateIcon
odsl.scriptRun a scriptrun [script]file-play text-office

The target works with any service and any action. It supports property-change filtering but not @transformer: shape the data inside the script instead.

Inputs​

InputDescription
scriptThe name of the ODSL script to run

What the script receives​

VariableDescription
#DATAThe data that triggered the automation
#PROPERTIESThe automation properties, including id, ondate and range, which are added automatically when they apply

For example, a script can read the id and date of the triggering item:

print "Automation fired for " + #PROPERTIES.id
print "Ondate: " + #PROPERTIES.ondate
d = #DATA

Example: run a script when a dataset is complete​

a = AutomationBuilder("dataset", "private", "MY.PROVIDER.FEED").build()

c = SimpleObject()
c.source = "private"
c.service = "dataset"
c.id = "MY.PROVIDER.FEED"
c.action = "complete"
conds = []
conds.add(c)
a.conditions = conds

a.target = "odsl.script"
a.template = "When 'MY.PROVIDER.FEED' is complete, run [script]"
a.icon = "file-play text-office"
a.properties.script = "post-process-feed"
a.enabled = true
save ${automation:a}

Example: run a script when a property changes​

This automation only fires when the status property of the curve is changed to approved. It uses property-change filtering, so both @propertyName and @propertyValue are set and the template uses the property-change form.

ab = AutomationBuilder("data", "private", "MY_OBJECT:CURVE")
ab.set("@propertyName", "status")
ab.set("@propertyValue", "approved")
a = ab.build()

c = SimpleObject()
c.source = "private"
c.service = "data"
c.id = "MY_OBJECT:CURVE"
c.action = "update"
conds = []
conds.add(c)
a.conditions = conds

a.target = "odsl.script"
a.template = "When property [@propertyName] on 'MY_OBJECT:CURVE' is set to [@propertyValue], run [script]"
a.icon = "file-play text-office"
a.properties.script = "publish-approved-curve"
a.enabled = true
save ${automation:a}
Script target or custom target?

The script target lets the person creating the automation choose any script. If you want to fix the script and ask only for specific inputs, create a Custom Target backed by your script instead. For multi-step work that should also be tracked as a process execution, use the Process Target.