DataMagik Script Engine v1.0

DataMagik Script Engine

Programmable Document Generation and Workflow Automation

Transform complex business processes into automated document workflows with custom JavaScript logic. The Script Engine gives you complete programmatic control over document generationβ€”from data transformation and validation to multi-step workflows and external API integrations.

DataMagik Script Engine

Server-Side Scripting for Plex

Extend Plex with Custom Logic

DataMagik Script Engine lets you write powerful server-side scripts that run within the DataMagik platform. Transform data, validate inputs, call external APIs, and build custom business logic - all with full access to Plex data.

Why Use the Script Engine?

When standard configurations aren't enough, scripts give you unlimited flexibility.

πŸ”§ Custom Business Logic

Implement complex business rules that go beyond what's possible with standard configuration. Calculate custom values, enforce validation rules, or implement industry-specific logic.

πŸ”„ Data Transformation

Transform data between formats, clean up inputs, merge data from multiple sources, or reshape data for external systems.

🌐 External API Integration

Call external REST APIs, web services, or third-party systems directly from your scripts. Get data from external sources or push updates to other platforms.

⚑ Real-Time Processing

Scripts execute in real-time when triggered. Process data instantly as users interact with Plex screens or when events occur.

Script Capabilities

Everything you need to build powerful integrations and automations.

πŸ“Š Plex Data Access

Read and write Plex data directly from your scripts. Query data sources, update records, and interact with Plex APIs.

Query Plex data sources

- Run queries against any Plex data source with parameters

Call Plex APIs

- Execute Plex web service APIs directly

Read screen context

- Access data from the current Plex screen

Write back to Plex

- Update Plex records through standard APIs

🌐 HTTP Requests

Make HTTP calls to external systems. Integrate with REST APIs, webhooks, and web services.

GET, POST, PUT, DELETE

- Full HTTP method support

Custom headers

- Set authentication tokens, content types, and custom headers

JSON/XML handling

- Parse and generate JSON and XML payloads

Error handling

- Catch and handle HTTP errors gracefully

πŸ” Secure Credential Storage

Store API keys, passwords, and tokens securely. Reference credentials in your scripts without exposing sensitive values in code.

Encrypted storage

- Credentials are encrypted at rest

Named references

- Reference credentials by name in scripts

Access control

- Control which scripts can use which credentials

Audit logging

- Track credential usage

πŸ“ Logging & Debugging

Built-in logging helps you develop, test, and troubleshoot your scripts.

Console logging

- Write debug messages during execution

Execution history

- View past script runs and their outputs

Error details

- Full stack traces when errors occur

Performance metrics

- See execution times and resource usage

πŸ“¦ Built-In Libraries

Common utilities are available out of the box. No need to reinvent the wheel.

Date/time handling

- Parse, format, and calculate dates

String manipulation

- Format, parse, and transform text

Math functions

- Calculations, rounding, and number formatting

Data validation

- Validate emails, phone numbers, and other formats

Encoding/decoding

- Base64, URL encoding, and more

The Script Editor

A modern, developer-friendly environment for writing scripts.

πŸ’» Modern Code Editor

Write scripts in a full-featured code editor with syntax highlighting, auto-completion, and error detection. Syntax highlighting for JavaScript Auto-complete for built-in functions Real-time error detection Code formatting Search and replace

▢️ Test & Debug

Run scripts directly in the editor with test data. See results instantly without deploying. Run with sample data View console output Inspect return values Step through errors

πŸ“š Documentation & Help

Built-in documentation for all available functions, objects, and APIs. Never leave the editor to find help. Function reference Code examples API documentation Best practices

How Scripts Get Triggered

Multiple ways to execute your scripts based on your needs.

πŸ–±οΈ From Plex Screens

Use DataMagik Automate to add buttons to Plex screens that trigger scripts. Users click and scripts execute with the current screen context.

πŸ“„ In Document Templates

Call scripts from document templates to calculate values, fetch additional data, or transform content before generation.

πŸ”— Via API

Trigger scripts via HTTP API from external systems. Pass parameters and receive results.

⏰ On Schedule

Schedule scripts to run automatically at specific times or intervals. Perfect for batch processing and scheduled integrations.

πŸ”„ From n8n Workflows

Call scripts as steps within n8n workflows. Combine visual workflow automation with custom script logic.

Example Use Cases

See what you can build with the Script Engine.

🏷️ Custom Barcode Generation

Generate complex barcode values that combine multiple fields with checksums and formatting rules.

Example: Create GS1-128 barcodes with application identifiers, dates, and serial numbers concatenated with proper formatting.

πŸ’° Custom Pricing Calculations

Calculate prices based on complex rules - volume discounts, customer tiers, material costs, and market factors.

Example: Calculate quoted price based on material weight, finishing costs, customer discount tier, and current steel market index.

πŸ“§ Smart Notifications

Send intelligent notifications to the right people based on complex conditions and escalation rules.

Example: When a quality hold exceeds 24 hours, escalate notification to quality manager. After 48 hours, include plant manager.

πŸ”— ERP Synchronization

Keep external ERP or accounting systems in sync with Plex data through real-time API calls.

Example: When an invoice is posted in Plex, create matching invoice in QuickBooks via API.

πŸ“Š Custom Data Validation

Validate data against complex business rules before allowing actions to proceed.

Example: Before releasing a shipper, verify all containers have valid weights, all required documents are attached, and customer credit is approved.

🌑️ IoT Data Processing

Process data from sensors, PLCs, or IoT devices and write results to Plex.

Example: Receive temperature readings from sensors, calculate averages, and log to Plex quality records.

πŸ“‹ Complex Report Generation

Aggregate and transform data for complex reports that can't be done with standard queries.

Example: Generate a customer scorecard combining on-time delivery, quality PPM, and cost savings across all programs.

πŸ”„ Data Migration & Cleanup

Batch process records for data cleanup, migration, or mass updates.

Example: Standardize phone number formats across all customer records.

Script Example

Here's what a simple script looks like.

Example: Get customer info and call external API

// Get customer data from current screen context
const customerId = context.screen.customerId;

// Query Plex for customer details
const customer = await plex.query('Customer_Get', {
  Customer_Key: customerId
});

// Call external CRM API
const crmResponse = await http.post('https://api.crm.com/customers', {
  headers: {
    'Authorization': credentials.get('crm-api-key'),
    'Content-Type': 'application/json'
  },
  body: {
    name: customer.Customer_Name,
    code: customer.Customer_Code,
    email: customer.Email
  }
});

// Return result
return {
  success: true,
  crmId: crmResponse.id,
  message: 'Customer synced to CRM'
};

Security & Governance

Enterprise-ready security for your scripts.

πŸ”’

Permission Control

- Control who can create, edit, and execute scripts πŸ‘οΈ

Execution Audit

- Full audit trail of all script executions ⏱️

Timeout Limits

- Scripts have execution time limits to prevent runaway processes 🚫

Sandboxed Execution

- Scripts run in isolated environments πŸ“Š

Resource Monitoring

- Track script resource usage and performance

Ready to Extend Plex with Custom Scripts?

Get started with DataMagik Script Engine and build the integrations your business needs.

Quick Info

Product
DataMagik Script Engine
Version
1.0
Type
Overview
Updated
Dec 27, 2025

Related Documentation

View All Docs