Automations
The Automations module enables users to extend the system with custom workflows. It allows running custom business logic, integrating with external systems, and scheduling automated tasks to improve efficiency and reduce manual work.
Use Cases:
- Run AI-powered data analysis and generate insights.
- Send automated email notifications based on specific triggers.
- Generate and export reports on a scheduled basis.
- Prepare PDF documents and attach them to the system.
- Integrate with third-party services for data synchronization.
- Perform data cleanup and maintenance tasks automatically.
- Run custom scripts to process data and update records in the system.
Examples:
- Pull exchange rates from an external API and update the system.
- Retrieve emails from an external mail server.
- Optimize video files within the system.
- Validate VAT numbers using the VIES service, generate a PDF confirmation, and attach to the system.
Prerequisites
- Python installed in
c:\Python - Python libs
pip install requests pyodbc uuid logging
Configuration
secrets:jetquery_var_automation_appname- name of the app authorized to run automations default erpsecrets:jetquery_var_automation_python- optional - location of python defaultc:\\Python\\python.exe
- Automations are stored in the
/automationsdirectory of the application. - Automation names must follow the format:
A001-YourAutomationName. - Only a single app instance is authorized to run automations.
Environment Variables
- Automation scripts read environment variables starting with
JETQUERY_.
Warning : environment variables are visible in a scope of the machine level (system environment) IIS/Kestrel. After restarting iis from gui or recycle it will not be visible iisreset is required
| Batchfile | |
|---|---|
Predefined:
JETQUERY_TOKEN– Represents the API token for authentication, reads from Environment variablesJETQUERY_TOKEN_+JETQUERY_HOST(e.g.,JETQUERY_TOKEN_app.platformaerp.com) token must match host/tenant other tokens are ignoredJETQUERY_HOST– Represents the host URL or tenant ID. exampleapp.platformaerp.com!WARNING! without scheme https:// or http://JETQUERY_DSN– Represents the database connection string.- If not provided, it is generated automatically, e.g.:
SERVER=192.1.1.1;DATABASE=ERP;UID=platforma;PWD=password;Trusted_Connection=no; - The driver must be added in the script, for example:
DRIVER={SQL Server};
- If not provided, it is generated automatically, e.g.:
JETQUERY_FILES– Path to the local tenant files.JETQUERY_ARCHIVE– Path to the local tenant temporary archive, which is cleaned automatically according to the data retention policy.JETQUERY_....All environment variables starting with JETQUERY_
automation.json
Stored in app directory automations\
API
Test automations using A000-run-test.
RUN Automation as a JOB
Starts an automation and returns a job ID for status polling.
Request (works with GET/POST):
options:
cron(optional queryparameter) - cron expression to schedule the automation, if not provided runs immediatelyargs(optional queryparameter) - additional arguments to pass to the script, for example:?args=arg1,arg2
Response:
| JSON | |
|---|---|
| Field | Type | Description |
|---|---|---|
data.jobid |
string | Job identifier, use to poll status |
data.jobstatus |
string | Relative URL for the status endpoint |
SCHEDULE Automation RUN
| HTTP | |
|---|---|
Exmaples of cron expressions:
* * * * *- every minute0 * * * *- every hour at minute 00 0 * * *- every day at midnight*/5 * * * *- every 5 minutes0 9 * * 1-5- 09:00 Monday–Friday
EXEC Automation immediately and wait for the result
Starts an automation and wait for the result, not recommended for long running tasks, use for testing and debugging only.
Request (works with GET/POST): options:
cron(optional queryparameter) - cron expression to schedule the automation, if not provided runs immediatelyargs(optional queryparameter) - additional arguments to pass to the script, for example:?args=--action arg2 --action2 test
POST http://localhost/api/core/automations/exec/A020-run-hanel?args=--action
| HTTP | |
|---|---|
Response:
| JSON | |
|---|---|
STATUS of the job
Returns the current state of a running or completed automation job.
Request:
Response:
| JSON | |
|---|---|
| Field | Type | Description |
|---|---|---|
data.jobstate |
string | Pending, Running, Succeeded, or Failed |
data.exitCode |
string | Process exit code returned by the automation script |
data.stdout |
string | Standard output from the script |
data.stderr |
string | Standard error output from the script |
BROWSE Automations
Lists all available automations. Requires role sys_administrator.
Request:
Other endpoints
| HTTP | |
|---|---|
Testing in local environment
SETUP ENVIRONMENT VARIABLES
Run cmd as administrator
| Batchfile | |
|---|---|
A002-tools-minimal - Basic dotnet template
you can find it in tests\test-files\A002-tools-minimal.cs
args:
--status[0/1/2] default 0- 0 = Success
- 1 = General failure (write to stderr)
- 2 = Incorrect usage / file not found (write to stderr)
--wait[s] default 5--msg[string] default: write all env vars and args as JSON to stdout