DataMagik Script Engine
Visual workflows and server-side JavaScript for Plex, with results straight into Excel.
Connect a trigger, a Plex query and an email on a canvas, test it step by step, and run it on a schedule, from a Plex screen, or by API. Developers get the same platform in JavaScript, and anything a script returns can be published to Excel, Power BI or Google Sheets as a link that refreshes itself.

Workflows for Plex
Build integrations by connecting steps, not writing code
Drag a trigger onto the canvas, add a Plex query, a decision and an email, and wire them together. Each step is a form you fill in. When you need more, the same workflow is JavaScript underneath, and the Script Engine is there for developers.
Why Workflows
Your power users build it. DataMagik runs it.
Drag, connect, run
Pick steps from a searchable palette and connect them on a canvas. Branches can split and join again anywhere, so the flow on screen is the flow that runs.
Plex, first class
Plex Data Source, Plex API and ODBC steps list the sources you can reach and build their input forms for you. They support reads and writes.
Test without risk
Run the workflow and see each step's input and output. On a test run, Plex writes and label printing are held back unless you say otherwise.
The editor
See the data at every step
Open any step to see what came in, the form, and what went out, side by side. View it as a table, JSON or schema. Drag a field from the input into the form, and the live preview shows the value it will produce.
Pin a step's data so you can keep working without calling Plex again. Run up to the step you are on, set breakpoints, and watch the console while it runs.
66 steps
Everything a plant integration needs
Plex
Plex Data Source, Plex API, ODBC Query.
Data
Set Fields, Lookup Table, Sort, Summarize, Calculate, Date & Time, Compare Datasets, Only New Items and more.
Logic
IF, Switch, Merge, Loop Over Items, Filter, Wait, and Run Script / Workflow.
Documents & labels
Generate documents one at a time or in a batch, merge PDFs, print labels with serial numbers.
Files
Read and write Excel, CSV and XML, read EDI, fill Excel templates, read PDF text, zip and unzip.
Messages
Send templated email, post to Teams or Slack, request an approval, answer an API caller.
AI
Prompt, extract fields, classify, write, and read scanned documents with OCR.
Systems
HTTP Request, databases on your network, PLC and shop floor tags, send EDI.
Code
A Code step for the one rule no form covers, written in JavaScript.
How a workflow starts
Runs on a schedule, on an event, or on request
Every workflow is saved as a Script Engine script. Schedules, API keys, run history and Integrations all work the same way they do for scripts.
Triggers
- Schedule: a time of day, a weekday, every few minutes.
- Manual / API: a button, or a call from another system with an API key.
- File Arrives and Email Arrives: a file on an endpoint or an email to an intake address.
- Tag Crosses a Limit: a PLC or shop floor value goes out of range.
- Platform Hook and When a Workflow Fails: react to events inside DataMagik.
Use it everywhere
- Run it from a Plex screen with DataMagik Automate, or from a dashboard or an app.
- Give it to an AI assistant as a tool, with its inputs described.
- Publish its result to Excel with Connect to Excel.
- Add it to an Integration to track its health with your other scripts.
Under the hood: JavaScript
Prefer code? It is all still there.
A workflow is turned into an ordinary JavaScript script that runs in a secure sandbox. Open the Code view to read exactly what will run, step by step.
Developers can write scripts directly in the Script Engine editor, with access to Plex, email, documents, files, lookup tables, credentials and HTTP. Use a Code step inside a workflow, or call a script from one with Run Script.
This script does the same job as a three-step workflow (Schedule, Plex Data Source, Send Email): every weekday at 07:00 it emails buyers the purchase orders that are late.
// Every weekday at 07:00 (schedule 0 7 * * 1-5): email buyers the purchase orders that are late.
function main(context) {
const result = plex.execute({
credentialName: "PLEX_BASIC_AUTH",
dataSourceId: "12345", // your "late purchase orders" data source
body: { Days_Late: 1 }
});
if (!result.success) {
return { success: false, script_message: "Plex failed: " + result.error };
}
const rows = result.data.rows || [];
if (rows.length === 0) {
return { success: true, data: { sent: false, count: 0 } };
}
const sent = email.sendWithTemplate("Late POs", { rows, count: rows.length },
{ to: ["buyers@yourcompany.com"] });
if (!sent.success) {
return { success: false, script_message: "Email failed: " + sent.error };
}
return { success: true, data: { sent: true, count: rows.length } };
}
Data for Excel
Your script is a spreadsheet now
Publish any read-only script to a link. Paste that link into Excel and it arrives as a live table that refreshes on its own. There is no Power Query code to write, no export to email around, and no copy of the data going stale in somebody's Downloads folder.
Copy the link
Open the script, click Connect to Excel, fill in any inputs, copy. The panel will not hand you a link until every required input has a value, so a link you copied is always complete.
Paste it into Excel
Data → From Web, paste, OK. Choose Anonymous when Excel asks how to sign in — the credential is already in the link.
Load, then stop thinking about it
The workbook refreshes on open, on Refresh All, or on a schedule in SharePoint. The numbers are current because they were fetched, not because somebody remembered to re-send them.
The panel also previews exactly what Excel will see, taken from the script's last real run — so you find out the shape is wrong before the workbook does.
Excel
CSV for a table that renders instantly, or XLSX when a column holds an identifier rather than a quantity. XLSX carries the types, so 00124735 stays 00124735 and 3-4 does not quietly become a date.
Power BI
The same script also publishes an OData feed with a typed schema. Get Data → OData feed and you are connected. $select, $top, $skip and $orderby all work, and paging holds one result so page two matches page one.
Google Sheets
One formula, same link:
=IMPORTDATA("https://data-magik.com/x/1324/dxl_….csv")
A link that is worth very little if it leaks
A token in a URL is genuinely weaker than one in a header. It sits in browser history, it gets pasted into chat, and it travels inside every workbook that saves it. So the token is built to be worth almost nothing on its own.
One token, one script. It cannot call anything else, and it cannot read the script's source.
Read-only, always. A script marked as a write script can never be published at all.
It runs as a named person. It sees exactly what that person's SQL Access Roles allow, and nothing more.
It expires. Ninety days by default, revocable instantly, rate-limited, and in the audit trail on every call.
Rotation without a scavenger hunt. Issue a new token and the old one keeps working for a grace period, so workbooks catch up on their own. The owner is emailed before a link expires.
Or turn tokens off entirely. An administrator can require an X-API-Key header company-wide, and existing links stop working the moment they do.
Published, findable, governed
Nobody has to ask a developer, and nothing goes unwatched
Data for Excel
A page in the main navigation listing everything published in your company — what it contains, what inputs it takes, and a copy button. No Builder permission, no script editor, no ticket. A script that has been switched on but never run says so, rather than looking ready.
Excel Links
Every link in the tenant in one table: what it reads, who it runs as, who created it, when it was last used, and how the last call actually went — so a workbook that stopped working explains itself instead of becoming a support ticket. Select and revoke in bulk.
Shaping a script for Excel
If it already returns rows, it is already publishable
A script that returns { data: { rows: […] } } needs no configuration at all — which is what most extract scripts already do.
function main(context) { const rows = odbc.executeQuery("parts_by_status", { status: context.part_status }); return { data: { columns: ["Part_No", "Name", "Qty"], rows: rows } }; }
Column order is yours to fix
Return a columns array beside your rows and the order is exactly what you wrote. Leave it out and columns come back as the sorted union of the row keys — sorted rather than arbitrary, because an order that shifted between refreshes would break every workbook bound to the link.
The result is always rectangular
Nested objects flatten one level into dotted columns. Anything deeper is JSON-encoded into the cell rather than reshaping the table under you.
Inputs become filters in the URL
The script's parameters arrive from the query string, so one published script serves every plant, customer or date range instead of one link per variation.
It warns you before it breaks someone's workbook
The editor flags it when a script stops returning a column it used to return — the change that silently empties a pivot table. Added columns are safe, and do not warn.
Refreshing costs one query, not one each
Turn on caching and a Refresh All across a department is a single run. The panel suggests a duration based on how long the script actually takes.
What a script can reach
Batteries included, and they are the right batteries
These are not libraries you install and wire up. They are already in the runtime, already authenticated, and already governed by your permissions.
Plex data sources
Call any Plex data source with URL routing, credentials, retry and backoff handled for you — reading and writing through the same APIs Plex uses itself.
SQL and ODBC
Run saved, parameterised queries against Plex's data warehouse — synchronously for a quick lookup, asynchronously when the result is large.
HTTP to anywhere allowed
Reach external REST APIs over an allow-listed host list, with secrets pulled from encrypted credential storage rather than pasted into code.
Documents and PDFs
Generate from a template one at a time, in parallel batches, or synchronously when you need the file back in hand. Merge PDFs and return them straight out of the script.
Send directly or from a template, with generated documents attached. Generate-then-send is a handful of lines, not an integration project.
Printers and the plant floor
Print labels through on-site connectors, render ZPL from templates, and read or write files on machines behind the firewall.
EDI, X12 and EDIFACT
Parse, validate, map and build interchanges structurally — with acknowledgements, conformance checking, duplicate detection and trading-partner routing.
OCR and AI
Pull structured fields off scanned documents with vendor-aware extraction profiles, and call language models for the judgement calls a regular expression cannot make.
Shipping
Rate shopping across carriers, parcel and LTL quotes, label creation and voiding, address validation and tracking.
Serial numbers
Traceability series that issue one number or a batch, without two scripts racing each other to the same value.
User defined tables
Storage for the cross-references and mappings that have no home in Plex — readable and writable from any script, with optional expiry.
Users and roles
Administer DataMagik roles and assignments from a script, so onboarding and access reviews can be automated instead of remembered.
How scripts run
Six ways in, one place to look when it goes wrong
From a Plex screen
DataMagik Automate puts a button on the screen. The script runs with that screen's context and answers back in place.
On a schedule
Nightly extracts, hourly syncs, month-end packets. Set the cadence and stop thinking about it.
From a spreadsheet
Excel's refresh is now a trigger. So is Power BI's, and Google Sheets'.
Over the API
An authenticated HTTP call from any external system, with parameters in and results back.
Inside a document template
Call a script mid-render to fetch what the template needs, or compute what the data does not carry.
From another script
Run one script from another, fan work out concurrently, or share common code through includes rather than copy-paste.
Security and governance
Built for somebody else to audit
Sandboxed, and bounded
Every script runs in an isolated runtime with a wall clock and a memory ceiling. A runaway script is stopped, not left to burn the platform down around it.
Secrets stay secrets
Credentials are encrypted at rest, referenced by name, scoped to the scripts allowed to use them, and never written into logs.
Permissions, not conventions
Who may write a script, who may run one, and who may publish data out of one are three separate permissions. Every route is tenant-scoped.
A record of every run
Execution history keeps the inputs, the console output, the return value, the duration and the outcome — so “it did not work” becomes a timestamp you can open.
Extend Plex on your terms
Build the logic your process needs as a workflow or in JavaScript, let DataMagik run it reliably — and hand the results to the people who live in a spreadsheet.
Book a DemoRelated Documentation
View All DocsWorkflows
Build automations by connecting steps on a canvas. Each workflow runs as a Script Engine script, so schedules, API keys, Executions and Integrations all work.
Workflow Step Reference
Every step in the workflow palette, by group, with its key options.
DataMagik Script Engine
JavaScript automations that run in DataMagik: what the Script Engine is, its screens, your first script, and what can start one.
Script Schedules
Run scripts and workflows by the clock: cron, time zones, retries, history and how missed or overlapping runs are handled.
Script Webhooks
Call a script from another system with an API key: the endpoint, request body, sync and async replies, and status codes.