Triggers — /triggers

A Collection with Input Parameters and a Delivery with an input contract (Input Payload, or write tags in OPC UA, Modbus, Sparkplug and PI) are event-driven: they only run when someone calls the CMS dynamic API with the values. That someone does not always exist — the calling system was never built, or the query is the same every day.
A Trigger solves this from inside CMS. It stores the fixed values an external producer would send and its own schedule. At the scheduled time it only creates the message with those values — the intention to collect or to deliver. The Interface scheduler is what runs it, as for any other message: with that Interface’s order, pause and block. A Trigger is a message generator with a schedule, not a second execution engine.
If the Collection runs and the source has no pending data, the Trigger’s message closes as Processed, with the attempt saying so — it is not an error. The Trigger’s values are stored separately, so a retry always uses them, even after an attempt that failed.
What shows up in the list
-
Collections: only those that require parameters — eligible for the dynamic API (HTTP, SQL Server, Oracle, SQLite, PostgreSQL, InfluxDB, MongoDB, SAP RFC, PI Web API) and with at least one declared Input Parameter. A regular pull Collection does not appear: it already runs on its own in the Interface scheduler, and a Trigger would make it run twice.
-
Deliveries: all of them, except those of the Help Desk tools — a ticket is opened by an alert or by the header button, not on a schedule. A Delivery only happens when someone hands it a message, so a Delivery Trigger is “create this message at this time”. One that declares an input contract (Input Payload, OPC UA or Modbus write tags, Sparkplug command metrics, PI write tags) opens in Fields, one per alias; one that does not opens straight in Body, where you write the message.
-
Routers: the Routers, for whoever has access to their screen — see Router target.
A Trigger that reads the UNS (UNS Snapshot mode or fields linked to variables) carries the UNS badge next to its name; the badge tooltip names the Snapshot or the linked fields.
If the Collection you are looking for is missing, its record does not declare Input Parameters yet — declare them there first.
Groups by Application
The list is not a single grid. Triggers are grouped by connection category and, within it, by the Application of the target Collection or Delivery. Each group uses the standard Application header, with the total and the active and inactive ones as subtle text (3 trigger(s) · 2 active · 1 inactive), the connection and the map. Groups open collapsed, as on the other screens; clicking the header identity opens and closes them. With a search typed in, they all open, to show what matched.
Inside a group there is no Application column — it is already in the header. The Interface column shows the sigla in its side’s color (Collection or Delivery) with the description below.
Triggers with a Router target sit in their own group, Routers, at the end of the screen, because a Router does not belong to an Application. There the row shows the Router code and name, the Interface column brings the number of destination Interfaces (clicking opens the list) and the Application column brings the destination Applications, with their icons.
In each group, active Triggers come first, then by name — clicking a column header re-sorts it. On an inactive Trigger, Last run shows in grey: it is history, not the current state.
Below the filter bar sits the total line, N Trigger(s), N active, with the All / Collection / Delivery / Router selector next to it, which filters by target type. The Router option only appears when there is a Router Trigger.
Creating a Trigger
- Name: free text, unique. It is the name shown under Schedulers.
- Target: pick Collection, Delivery or Router and the definition (or the Router). The Application and Interface combos are only a funnel to find the definition; picking the definition straight from the search fills both in.
- Parameters: one field per alias of the contract. A required alias without a default must be
filled; empty uses the default from the record, when there is one. For equipment targets (OPC UA,
Modbus, Sparkplug, PI) the screen shows the destination of each value and warns that the values
will be written to the equipment at the scheduled time.
- On a Collection, a switch toggles between Fields and JSON: the same alias object, just edited as text — handy for pasting the body that already lives in an external tool. Going back to Fields requires a valid flat JSON.
- On a Delivery, the switch toggles between Fields and Body. In Body you write the whole message, in the Content-Type you choose (JSON, XML or text), and it enters through the same path as an external POST: Content-Type validation, Transformer and Business Errors of the Delivery. Switching to Body starts the text with the JSON of the filled fields; switching back, a flat JSON becomes fields again, while XML or nested JSON starts with empty fields. If the body is JSON and the Delivery declares a contract, required aliases are still checked on save; XML and text are left to the Delivery itself, as for any producer.
- With the UNS module, the Delivery and the Router have a third mode, UNS Snapshot: the body is the JSON of a Snapshot, built at firing time. See Body: UNS Snapshot.
- Also with the UNS module, each field can be linked to a UNS variable through the icon next to it: instead of a fixed value, the field gets the current value of the variable at firing time (the order in production, the line’s batch). The linked field shows the topic, and the same icon unlinks it. If the variable has no value yet, the field goes without a value. Linking requires reading the variable in UNS access control.
- Schedule, in five modes: every N seconds/minutes/hours; daily (optionally weekdays only); weekly (selected days and time); monthly (day 1 to 28 or the last day of the month); or a cron expression. The screen shows the readable sentence and the next three runs, in the server time zone.
Parameter values accept the same placeholder syntax as Collections: {{dataHoraAtual}},
{{ultimaExecucao}} (the last run of this Trigger — empty on the first) and {{NAME}} of a
Global or Application Variable. This is what lets a Trigger do incremental sweeps — “orders since
last time” — with no external system at all. The { } button next to each value (and to the
body) lists the two placeholders and the available Variables. A placeholder without a value
becomes empty.
Enable, pause, run now
Every Trigger is born disabled. Creating one runs nothing.
- Enabling only happens on the Trigger, not under Schedulers: through the Active column of the list, after a confirmation that shows the target, the parameters, the frequency and the next run; or through the Active / Inactive switch in the form footer, which applies on Save (the form already shows the target and the schedule). The rule lives on the server: trying to enable a Trigger from the Schedulers screen is refused, and that screen sends you here.
- Pausing is immediate through the Active column, from here or from Schedulers; through the form switch, it applies on Save.
- Run now creates the message outside the schedule — and, as with the schedule, the Interface scheduler is what runs it. On a “last day of the month” Trigger the manual run ignores the day rule — that is exactly what it is for.
What happens on a run
- Collection: a message is born with the fixed parameters, waiting. On the next cycle of the Collection’s Interface, the scheduler queries the source with those parameters, and the same message follows the configured forwarding. With the Interface paused or the source Application offline, the messages wait until it comes back. If the query fails, it is retried on the following cycles up to the Collection’s Max. Attempts.
- Delivery: a message is born on the Interface — with the body
{alias: value}in Fields mode, or with the raw text and the chosen Content-Type in Body mode — and follows the normal flow — Transformer, Business Errors, retries. The message is not flagged as a test. - Disabled target, a contract that changed and left a required alias empty, a failure at the source: all become an error in the scheduler history and in the “Last run” column. The Trigger does not disable itself — pausing is your call, looking at the error.
- On the Messages screens, a message generated by a Trigger carries a discreet bolt next to the status, with the Trigger name in the tooltip; the detail popup and the detail page show the bolt with the name. It is only an origin mark, with no shortcut: unlike a test message, it is real traffic and counts in dashboards and reports.
Router target
With the Router target (the Router icon, in indigo), a combo lists the Routers by code and name, and the screen loads the contract fields of the chosen one. Fields and Body modes work as for a Delivery; a Router without a contract only has Body.
When it fires, the payload enters the Router as an external POST: it checks the contract and creates a message in each Delivery the flow reaches. The Router execution gets the Trigger origin and the Trigger name.
- Out of contract: the Reject policy becomes Record, since nobody would receive a 400, and the Trigger run ends in error.
- Variables: in the values,
{{NAME}}only works for Global Variables — a Router belongs to no Application. - Permission: creating or viewing a Trigger with a Router target requires access to the Routers screen.
Body: UNS Snapshot
With the UNS module, the Delivery and the Router get the UNS Snapshot mode, next to Fields and
Body. You pick a Snapshot (a selection of namespace nodes) and, on every firing,
the Trigger reads the current values and sends the Snapshot JSON as the body, with the Trigger name
in gatilho. Preview shows the JSON with the current values, at the same size as the JSON field,
and warns if any value would be over the maximum age. Clicking the preview opens the large editor,
read-only.
- One Snapshot, one Trigger: the combo only lists Snapshots without a Trigger (or this one’s). A second Trigger on the same Snapshot is refused; for two destinations, use a Router.
- Maximum age: if the Snapshot defines one and some value is older at firing time, the run becomes an error, with the old variables in the message, and no message is created.
- From the Snapshots screen: Create Trigger with this snapshot and Edit Trigger open this same form over the Snapshots screen, with the Snapshot fixed.
- Once saved: opened from this screen, a Trigger with a Snapshot shows the Snapshot fixed, with a padlock. The Fields and Body modes and the Collection type are locked, and the link becomes Change in Snapshots — the link between Snapshot and Trigger is changed on the Snapshots screen. Name, description, schedule and enabling stay editable here. On a new Trigger, the Snapshot is chosen freely.
- The Delivery must accept JSON; its Transformer can change the format.
Trigger’s Transformer
Not every destination wants the Snapshot JSON the way it comes out. The Transformer field, in UNS Snapshot mode, applies a Transformer to the JSON before the message is born. It is optional; left empty, the Snapshot JSON goes as is.
- It lives on the Trigger, not on the Snapshot: the format is a requirement of whoever receives it, and the same Snapshot may serve a Collection that wants the original JSON.
- The preview shows both sides: with a Transformer, Preview opens on What the Trigger sends and switches to Snapshot JSON. If the Transformer fails, the preview shows the error.
- The Content-Type follows the output: a Transformer that returns XML sends XML; JSON goes as JSON.
- A failure sends nothing: a disabled Transformer, or one that errors at firing time, leaves the run in error and no message is created — the raw JSON never goes out in its place.
- The Delivery can still have its own: if the Delivery has its own Transformer, it runs afterwards, as for any producer. Use one of the two, or make sure the Delivery’s one expects what the Trigger’s one produces.
- The Transformer can also be chosen from the Snapshots screen.
Under Schedulers
Each Trigger is a trigger-<id> scheduler, listed in the Triggers group of
Schedulers under the name you gave it. There you can pause, run now and see
the run history; editing the schedule and enabling are done here.
History
Two histories, behind different buttons on the row:
- Runs — every firing, with duration, result and message (the scheduler history itself).
- Changes — who created it, who changed what (before and after), who enabled, disabled, ran manually or deleted it. Comes from the audit log.
Import/Export, Packs and MCP
Triggers travel in Import/Export as the Triggers domain, referencing the target definition by
its code. A Pack can declare Triggers for its own Collections and Deliveries. Through the
MCP Server, cms_list_triggers lists and cms_create_trigger creates. In
every case the Trigger arrives disabled. The Snapshot and the UNS variables travel by name and
by topic; the Snapshot itself goes in the UNS package in Transport (see
Snapshots › move to another environment). Triggers with a Router target stay out of
Import/Export: the Router is not in that package, and travels through its
own export.
Permission
The Tool is /triggers, in the Integration group, right after Routers. The scope is the same
as the other master-data screens: you see the Triggers whose target definitions are in your
Interfaces.