Overview
ERPLite provides a low-code scripting environment for advanced users to write JavaScript for data manipulation, calculations, and dynamic logic.JavaScript
Write standard JavaScript code
Libraries Included
Lodash and Luxon pre-loaded
Test Environment
Test scripts with mock data
Data Access
Access all task and user data
Supported Libraries
| Library | Purpose | Documentation |
|---|---|---|
| Lodash | Utility functions for arrays, objects, strings | lodash.com |
| Luxon | Date/time manipulation and formatting | moment.github.io/luxon |
Where to Use Scripts
Scripts can be used anywhere you see the JS icon in ERPLite:- Component value bindings
- Automation conditions
- Validation expressions
- Computed values
- Action configurations
Writing Scripts
Basic Syntax
Scripts must return a value using thereturn statement:
Accessing Data
Testing Scripts
1
Open Script Editor
Click the JS icon to open the script editor
2
Write Your Code
Enter your JavaScript code
3
Update Mock Data
Click Update Mock Data to set test values
4
Run Test
Click the Run button to execute
5
Check Output
Verify the result in the output box
The output type must match what the component expects. A number field requires a number output.
Examples
String Manipulation
Working with Arrays (Lodash)
Date/Time (Luxon)
Calculations
Conditional Logic
Best Practices
Keep Scripts Simple
Keep Scripts Simple
Complex logic is harder to debug. Break into smaller pieces if needed.
Handle Null Values
Handle Null Values
Always check if data exists before using it:
Use Meaningful Variables
Use Meaningful Variables
Name variables clearly for better readability.
Test Edge Cases
Test Edge Cases
Test with empty values, nulls, and boundary conditions.
For AI Agents
Script Context Variables
| Variable | Description |
|---|---|
task | Current task object |
task.data | User-defined data fields |
task.taskId | Task identifier |
task.status | Current task status |
loggedInUser | Current user object |
loggedInUser.name | User’s name |
loggedInUser.role | User’s role |
loggedInUser.team | User’s team |
_ | Lodash library |
DateTime | Luxon DateTime class |
Script Execution
UI Components
| Component | Location | Purpose |
|---|---|---|
| ScriptEditor | /src/components/LowCode/ScriptEditor/ | Code editing |
| MockDataEditor | /src/components/LowCode/MockData/ | Test data configuration |
| ScriptRunner | /src/components/LowCode/Runner/ | Script execution |
Error Handling
Scripts that throw errors will:- Log the error to automation logs
- Return
undefinedor fail the action - Display error message in test mode