Skip to main content

Execution Engine

Overview

The Execution Engine is the command execution framework that powers BankLingo's Process Automation. It provides a comprehensive set of commands for interacting with the banking system, executing business logic, and integrating with external services.

Key Features

🚀 65+ Built-in Commands

  • Communication commands (Email, SMS)
  • Query commands (50+ data retrieval commands)
  • Transaction commands (Loans, Deposits, Transfers)
  • Document generation commands
  • API integration commands
  • Business rule execution

📝 JavaScript Scripting

  • Full JavaScript support via Jint engine
  • Access to all system commands via doCmd()
  • Rich context object with workflow data
  • Utility functions (crypto, encoding, validation)

🔌 Seamless Integration

  • Direct integration with Process Engine
  • Event-driven command execution
  • Context-aware operations
  • Real-time data access

🛡️ Secure Execution

  • Sandboxed JavaScript environment
  • Secure credential management
  • Audit trail for all executions
  • Error handling and logging

Command Categories

Communication Commands

Send notifications and alerts:

  • SendEmailCommand - Send emails with templates
  • SendSMSCommand - Send SMS notifications

Query Commands (50+)

Retrieve data from the system:

  • GetFullTableQuery ⭐ - Query custom BPM tables
  • DoSqlQuery ⭐ - Execute SQL queries
  • RetrieveLoanListQuery - Get loan lists
  • RetrieveLoanByIdQuery - Get loan details
  • RetrieveDepositListQuery - Get deposit accounts
  • RetrieveContactListQuery - Get customer data
  • ... and 40+ more query commands

Transaction Commands

Create and manage transactions:

  • CreateLoanCommand - Create new loans
  • UpdateLoanCommand - Update loan details
  • CreateDepositCommand - Create deposits
  • InitiateDepositCommand - Deposit money
  • InitiateWithdrawalCommand - Withdraw money
  • InitiateTransferCommand - Transfer funds

Document Commands

Generate documents and reports:

  • GenerateDocumentCommand - Generate from templates
  • RenderHtmlCommand - Render HTML content
  • GeneratePDFCommand - Create PDF documents

API Commands

Integrate with external systems:

  • APICallCommand - Make HTTP API calls
  • HttpInvoke - Execute HTTP requests

Business Rule Commands

Execute business logic:

  • BusinessRuleCommand - Execute rule sets
  • ExecuteScriptCommand - Run C# scripts

System Commands

Database and system operations:

  • QueryTableCommand - Query database tables
  • InsertTableCommand - Insert records
  • UpdateTableCommand - Update records

Using Commands

doCmd() Function

All commands are executed using the doCmd() function:

var result = doCmd('CommandName', {
parameter1: value1,
parameter2: value2
});

if (result.isSuccessful) {
// Use result.data
context.myResult = result.data;
} else {
// Handle error
throw new Error(result.message);
}

Example: Send Email

var emailResult = doCmd('SendEmailCommand', {
email: [context.customer.email],
subject: 'Loan Application Status',
message: '<h1>Your loan has been approved!</h1>',
sender: 'noreply@banklingo.app'
});

Example: Query Data

// Query custom BPM table
var pricingResult = doCmd('GetFullTableQuery', {
Data: {
table: 'tblLoanPricing',
filter: 'MinAmount <= ' + context.amount + ' AND MaxAmount >= ' + context.amount
}
});

// Query with SQL
var loanResult = doCmd('DoSqlQuery', {
Data: {
sql: 'SELECT * FROM Loans WHERE CustomerId = ' + context.customerId,
timeout: 30000
}
});

Context Object

The context object provides access to all workflow data:

// Access form data
context.form.loanAmount
context.form.customer.email

// Access entity data
context.loan.principalAmount
context.customer.creditScore
context.deposit.balance

// Access user data
context.user.fullName
context.user.branchId
context.user.role

// Access system data
context.system.currentDate
context.system.currentDateTime

// Store results
context.lastScriptResult
context.lastServiceResult
context.customVariable = "value"

Utility Functions

Cryptographic Functions

// Hash functions
var hash = sha256("hello world");
var hash512 = sha512("secret data");
var hmac = hmacSha256("secret-key", "payload");

// Encoding functions
var encoded = base64Encode("BankLingo");
var decoded = base64Decode("QmFua0xpbmdv");

Date Functions

// Format dates
var formatted = formatDate(new Date(), "yyyy-MM-dd");

// Date arithmetic
var futureDate = addDays(new Date(), 30);
var futureMonth = addMonths(new Date(), 6);

// Date difference
var daysDiff = dateDiff(date1, date2, "days");

Validation Functions

// Validate email
var isValid = isValidEmail("user@example.com");

// Validate phone
var isValidPhone = isValidPhone("+2348012345678");

// Check if numeric
var isNum = isNumeric("12345");

Secure Functions

// Access secure configuration
var apiKey = $.secure.get("EXTERNAL_API_KEY");
var password = $.secure.get("CORE_BANKING_PASSWORD");

Helper Libraries

Transaction Monitoring Library

$.monitoring = {
exceedsThreshold: function(amount, threshold) { ... },
calculateRiskScore: function(transaction) { ... },
validatePattern: function(transactions) { ... }
};

Validation Library

$.validate = {
email: function(email) { ... },
phone: function(phone) { ... },
bvn: function(bvn) { ... },
accountNumber: function(accountNumber) { ... }
};

Formatting Library

$.format = {
currency: function(amount, currency) { ... },
date: function(date, format) { ... },
phone: function(phone, countryCode) { ... }
};

Error Handling

Always handle errors in your scripts:

try {
var result = doCmd('CreateLoanCommand', {
principalAmount: context.amount,
customerId: context.customerId
});

if (!result.isSuccessful) {
throw new Error('Loan creation failed: ' + result.message);
}

context.loanId = result.data.id;
return { success: true, loanId: result.data.id };

} catch (error) {
console.error('Error creating loan:', error.message);
return { success: false, error: error.message };
}

Best Practices

✅ Do's

  • Always check result.isSuccessful
  • Store important results in context
  • Use try-catch for error handling
  • Validate inputs before calling commands
  • Use utility functions for common operations
  • Test scripts with sample data
  • Document complex logic

❌ Don'ts

  • Don't ignore error responses
  • Don't hardcode sensitive data
  • Don't create infinite loops
  • Don't bypass validation
  • Don't fetch large datasets without pagination
  • Don't use commands without understanding their purpose

Command Reference

GetFullTableQuery

Query custom BPM tables for configuration and lookup data.

View Full Documentation →

DoSqlQuery

Execute SQL queries for complex reporting and analytics.

View Full Documentation →

SendEmailCommand

Send email notifications with template support.

View Full Documentation →

RetrieveLoanListQuery

Retrieve loan data with filtering and pagination.

View Full Documentation →

All Commands

Browse the complete command reference:

Quick Start Examples

Example 1: Loan Approval Workflow

// Step 1: Get customer credit score
var customerResult = doCmd('RetrieveContactByIdQuery', {
Data: { id: context.customerId }
});

var creditScore = customerResult.data.creditScore;

// Step 2: Get pricing from config table
var pricingResult = doCmd('GetFullTableQuery', {
Data: {
table: 'tblLoanPricing',
filter: 'MinAmount <= ' + context.loanAmount + ' AND MaxAmount >= ' + context.loanAmount
}
});

var pricing = pricingResult.data.rows[0];

// Step 3: Apply decision logic
if (creditScore >= 700 && context.loanAmount <= 1000000) {
return { approved: true, interestRate: pricing.InterestRate };
} else {
return { approved: false, reason: 'Credit score or amount requirement not met' };
}

Example 2: Send Notification

// Get customer email
var customer = context.customer;

// Send approval email
var emailResult = doCmd('SendEmailCommand', {
email: [customer.email],
subject: 'Loan Approved - ' + context.loan.id,
templateId: 'loan-approval-template',
context: {
customerName: customer.firstName + ' ' + customer.lastName,
loanAmount: context.loan.principalAmount,
approvalDate: context.system.currentDate
}
});

return { emailSent: emailResult.isSuccessful };

Example 3: Complex Reporting

// Get branch performance data
var reportData = doCmd('DoSqlQuery', {
Data: {
sql: 'SELECT B.BranchName, COUNT(L.Id) AS TotalLoans, SUM(L.PrincipalAmount) AS TotalDisbursed ' +
'FROM Loans L INNER JOIN Branches B ON L.BranchId = B.Id ' +
'WHERE L.DisbursementDate >= DATEADD(month, -1, GETDATE()) ' +
'GROUP BY B.BranchName ORDER BY TotalDisbursed DESC',
timeout: 60000
}
});

// Store in context for reporting
context.branchPerformance = reportData.data;
return reportData;

Next Steps

Support

For questions or issues with Execution Engine: