Execute Your First Script
Learn how to test and execute your first Accela script using the RadishKit CLI and web interface
Now that you have RadishKit set up, let's execute your first Accela script. This guide will walk you through testing a script safely and understanding the results.
Prerequisites
Before executing your first script, ensure you have:
- RadishKit account with an agency and environment configured
- CLI installed and linked to your environment
- VS Code extension installed (optional but recommended)
- Wrapper script installed in your Accela environment
Understanding Script Testing
Safe Testing with Rollback
RadishKit uses a rollback mechanism for safe script testing:
- Test mode (default): Scripts run but changes are automatically rolled back
- Commit mode: Scripts run and changes are committed to the database
- Always test first: Never run in production mode without testing
Script Types
RadishKit supports several types of Accela scripts:
- Solution Scripts: General-purpose scripts for data manipulation
- Event Scripts: Scripts triggered by Accela events (ASA, WTUA, IRSA)
- Batch Scripts: Scheduled or bulk processing scripts
- SQL Queries: Direct database queries for data analysis
Your First Script Test
Step 1: Create a Simple Script
Create a basic test script to verify your setup:
// Scripts/Solution/HelloWorld.js function main() { // Simple test script var message = "Hello from RadishKit!"; console.log(message); // Return success return { success: true, message: message }; }
Step 2: Test the Script
Run your first script test:
accli test script Scripts/Solution/HelloWorld.js
Step 3: Understand the Results
The CLI will display:
- Script execution status
- Console output from your script
- Return values from the script
- Execution time and performance metrics
Interactive Parameter Mode
When you run a script without parameters, the CLI will ask:
Option 1: Run Without Parameters
Do you want to run without parameters? (y/n)
- Yes: Execute the script as-is
- No: Proceed to parameter selection
Option 2: Use Existing Parameter Set
Use existing parameter set? (y/n)
- Yes: Select from previously saved parameter sets
- No: Create new parameters
Option 3: Create New Parameter Set
Enter parameters for this script: Parameter 1: value1 Parameter 2: value2
- Enter parameters interactively
- Parameters are saved for future use
Non-Interactive Mode
For automation and scripting, use the --param
flag:
accli test script Scripts/Solution/MyScript.js \ --param "recordId=PR2024-001" \ --param "status=Complete" \ --param "department=Building"
Testing Different Script Types
Solution Scripts
# Basic solution script accli test script Scripts/Solution/UpdateRecord.js # With parameters accli test script Scripts/Solution/UpdateRecord.js \ --param "recordId=PR2024-001" \ --param "newStatus=Approved"
Event Scripts
# ASA (ApplicationSubmitAfter) event accli test event asa Scripts/Event/ASA_Handler.js --record "PR2024-001" # WTUA (WorkflowTaskUpdateAfter) event accli test event wtua Scripts/Event/WTUA_Handler.js \ --record "PR2024-001" \ --task "Review" \ --status "Complete" # IRSA (InspectionResultSubmitAfter) event accli test event irsa Scripts/Event/IRSA_Handler.js \ --record "PR2024-001" \ --inspection "Electrical"
Batch Scripts
# Basic batch script accli test batch Scripts/Batch/DailyReport.js # With parameters accli test batch Scripts/Batch/DailyReport.js \ --param "StartDate=2024-01-01" \ --param "EndDate=2024-01-31" \ --param "Department=Building"
SQL Queries
# Basic SQL query accli test sql queries/MyQuery.sql # Remove safety limit (use with caution) accli test sql queries/MyQuery.sql --no-limit
Understanding Results
Successful Execution
A successful script execution will show:
- Status: "SUCCESS" or "COMPLETED"
- Execution time: How long the script took to run
- Console output: Any console.log() messages
- Return values: Data returned by the script
- Database changes: What was modified (in test mode, these are rolled back)
Error Handling
If a script fails, you'll see:
- Error message: What went wrong
- Stack trace: Where the error occurred
- Execution logs: Detailed error information
- Suggestions: How to fix the issue
Rollback Confirmation
In test mode, you'll see:
- Rollback status: "Changes rolled back successfully"
- Data restored: Original data is restored
- Safe testing: No permanent changes made
Monitoring and Logs
Viewing Execution Logs
- In the CLI: Results are displayed in the terminal
- In RadishKit Web: Go to your agency → Scripts → Executions
- Detailed logs: Click on any execution for full details
Understanding Logs
Execution logs include:
- Script content: The actual script that was executed
- Parameters used: All parameters passed to the script
- Console output: All console.log() messages
- Database changes: What was modified
- Performance metrics: Execution time and resource usage
Best Practices
Development Workflow
- Write your script in VS Code with the extension
- Test locally using the CLI
- Review results in the web interface
- Iterate and improve based on results
- Deploy when ready using production mode
Testing Strategy
- Start simple: Test basic functionality first
- Add complexity: Gradually add more features
- Test edge cases: Try different parameter combinations
- Review thoroughly: Check all execution logs
- Get approval: Have team members review before production
Parameter Management
- Save common parameters: Use the interactive mode to save frequently used parameters
- Document parameters: Add comments explaining what each parameter does
- Test variations: Try different parameter combinations
- Version control: Include parameter documentation in your scripts
Troubleshooting
Common Issues
Script not found:
- Check the file path is correct
- Ensure the script file exists
- Verify you're in the right directory
Execution errors:
- Check the script syntax
- Verify all required parameters are provided
- Review the error message for clues
Connection issues:
- Run
accli status
to check your connection - Verify your environment is properly configured
- Check that the wrapper script is installed in Accela
Permission errors:
- Ensure your Accela user has script execution permissions
- Check that the wrapper script is properly installed
- Verify your credentials are correct
Getting Help
For script execution issues:
- Check the logs in the RadishKit web interface
- Review error messages for specific guidance
- Contact support at aaron@radishapps.com
- Check documentation for additional help
Next Steps
Congratulations! You've successfully executed your first script. Now you can:
- Learn CLI Commands - Master all CLI commands
- Explore Data Queries - Use the web interface for SQL queries
- Manage Scripts - Organize and deploy your scripts
- Team Collaboration - Work with your team
Ready to learn more about the CLI? Continue to CLI Commands!