Skip to main content

GetContextLoadersQuery

Overview

Retrieves a list of available context loaders for process variable initialization.

Purpose

Lists all context loader types that can be used to automatically initialize process variables from entity data (loan accounts, deposit accounts, clients, transactions, etc.).

Command Type

CB.Administration.Api.Commands.BPM.Process.GetContextLoadersQuery


Request

{
"cmd": "GetContextLoadersQuery",
"data": {
"category": "Lending"
}
}

Request Fields (data object)

FieldTypeRequiredDefaultDescription
categorystringNonullFilter context loaders by category (null = all)

Response

{
"isSuccessful": true,
"statusCode": "00",
"data": {
"contextLoaders": [
{
"type": "LoanApplicationContext",
"category": "Lending",
"description": "Loads loan account data into process variables",
"entityType": "LoanAccount",
"requiredFields": ["loanId"],
"variables": [
{
"name": "loanId",
"type": "long",
"description": "Loan account ID",
"required": true,
"example": 12345
},
{
"name": "amount",
"type": "decimal",
"description": "Loan amount requested",
"required": false,
"example": 50000.00
},
{
"name": "clientId",
"type": "long",
"description": "Associated client ID",
"required": false,
"example": 789
},
{
"name": "productId",
"type": "long",
"description": "Loan product ID",
"required": false,
"example": 5
},
{
"name": "branch",
"type": "object",
"description": "Branch information",
"required": false,
"example": { "id": 1, "name": "Main Branch" }
},
{
"name": "status",
"type": "string",
"description": "Loan application status",
"required": false,
"example": "PENDING_APPROVAL"
},
{
"name": "interestRate",
"type": "decimal",
"description": "Loan interest rate",
"required": false,
"example": 12.5
},
{
"name": "tenure",
"type": "int",
"description": "Loan tenure in months",
"required": false,
"example": 24
}
]
},
{
"type": "DepositAccountContext",
"category": "Deposits",
"description": "Loads deposit account data into process variables",
"entityType": "DepositAccount",
"requiredFields": ["accountId"],
"variables": [
{
"name": "accountId",
"type": "long",
"description": "Deposit account ID",
"required": true,
"example": 54321
},
{
"name": "accountNumber",
"type": "string",
"description": "Account number",
"required": false,
"example": "1234567890"
},
{
"name": "balance",
"type": "decimal",
"description": "Current account balance",
"required": false,
"example": 10000.50
},
{
"name": "accountType",
"type": "string",
"description": "Type of deposit account",
"required": false,
"example": "SAVINGS"
},
{
"name": "clientId",
"type": "long",
"description": "Account owner client ID",
"required": false,
"example": 789
}
]
},
{
"type": "ClientContext",
"category": "Customer Management",
"description": "Loads client data into process variables",
"entityType": "Client",
"requiredFields": ["clientId"],
"variables": [
{
"name": "clientId",
"type": "long",
"description": "Client ID",
"required": true,
"example": 789
},
{
"name": "clientCode",
"type": "string",
"description": "Unique client code",
"required": false,
"example": "CL-2026-001"
},
{
"name": "firstName",
"type": "string",
"description": "Client first name",
"required": false,
"example": "John"
},
{
"name": "lastName",
"type": "string",
"description": "Client last name",
"required": false,
"example": "Doe"
},
{
"name": "email",
"type": "string",
"description": "Client email address",
"required": false,
"example": "john.doe@example.com"
},
{
"name": "phone",
"type": "string",
"description": "Client phone number",
"required": false,
"example": "+2341234567890"
},
{
"name": "clientType",
"type": "string",
"description": "Individual or Corporate",
"required": false,
"example": "INDIVIDUAL"
}
]
},
{
"type": "TransactionContext",
"category": "Transactions",
"description": "Loads transaction data into process variables",
"entityType": "Transaction",
"requiredFields": ["transactionId"],
"variables": [
{
"name": "transactionId",
"type": "long",
"description": "Transaction ID",
"required": true,
"example": 99999
},
{
"name": "amount",
"type": "decimal",
"description": "Transaction amount",
"required": false,
"example": 5000.00
},
{
"name": "type",
"type": "string",
"description": "Transaction type",
"required": false,
"example": "DEPOSIT"
},
{
"name": "accountId",
"type": "long",
"description": "Associated account ID",
"required": false,
"example": 54321
},
{
"name": "reference",
"type": "string",
"description": "Transaction reference",
"required": false,
"example": "TXN-2026-001"
},
{
"name": "transactionDate",
"type": "datetime",
"description": "Transaction timestamp",
"required": false,
"example": "2026-01-06T14:30:00Z"
}
]
}
]
}
}

Available Context Loaders

Lending Category

LoanApplicationContext

Purpose: Auto-load loan account data when process starts from loan creation
Trigger Events: OnLoanCreation, OnLoanDisbursement, OnLoanRepayment
Key Variables: loanId, amount, clientId, productId, status, interestRate, tenure

Deposits Category

DepositAccountContext

Purpose: Auto-load deposit account data
Trigger Events: OnDepositCreation, OnAccountOpening
Key Variables: accountId, accountNumber, balance, accountType, clientId

Customer Management Category

ClientContext

Purpose: Auto-load client information
Trigger Events: OnClientCreation, OnClientUpdate
Key Variables: clientId, clientCode, firstName, lastName, email, phone, clientType

Transactions Category

TransactionContext

Purpose: Auto-load transaction data
Trigger Events: OnTransactionCreation, OnCashDeposit, OnCashWithdrawal
Key Variables: transactionId, amount, type, accountId, reference, transactionDate


Usage Workflow

1. Query Available Context Loaders

// Get all context loaders for a category
const response = await getContextLoaders({
category: "Lending"
});

console.log('Available Context Loaders:');
response.data.contextLoaders.forEach(loader => {
console.log(`\n${loader.type}:`);
console.log(` Description: ${loader.description}`);
console.log(` Variables: ${loader.variables.map(v => v.name).join(', ')}`);
});

2. Choose Appropriate Loader

const loaders = await getContextLoaders({ category: "Lending" });
const loanLoader = loaders.data.contextLoaders.find(l => l.type === "LoanApplicationContext");

console.log(`Using: ${loanLoader.type}`);
console.log(`Available variables for BPMN:`);
loanLoader.variables.forEach(v => {
console.log(` \${${v.name}} - ${v.description} (${v.type})`);
});

3. Create Process with Context Loader

// After querying available loaders
const loanLoader = loaders.data.contextLoaders.find(l => l.type === "LoanApplicationContext");

// Create process using the loader
await createProcessDefinition({
name: "Loan Approval Workflow",
category: "Lending",
contextLoaderType: loanLoader.type, // Use the loader
triggerEvents: ["OnLoanCreation"],
bpmnXml: `
<process>
<startEvent id="start"/>
<scriptTask id="checkAmount" scriptFormat="javascript">
<script>
// Can now use variables from LoanApplicationContext
if (loanAmount > 50000) {
execution.setVariable("requiresManagerApproval", true);
}
</script>
</scriptTask>
<userTask id="managerApproval" name="Manager Approval">
<documentation>
Loan Amount: \${amount}
Client: \${clientId}
Product: \${productId}
</documentation>
</userTask>
</process>
`
});

Variable Usage in BPMN

Script Task Example

<scriptTask id="validateLoan" name="Validate Loan" scriptFormat="javascript">
<script><![CDATA[
// Variables from LoanApplicationContext are automatically available
var loanAmount = execution.getVariable("amount");
var clientId = execution.getVariable("clientId");
var productId = execution.getVariable("productId");

// Business logic
var requiresApproval = loanAmount > 50000;
execution.setVariable("requiresManagerApproval", requiresApproval);

console.log("Loan " + loanId + " for amount " + loanAmount + " requires approval: " + requiresApproval);
]]></script>
</scriptTask>

Expression Example

<sequenceFlow id="flow1" sourceRef="gateway1" targetRef="managerApproval">
<conditionExpression xsi:type="tFormalExpression">
${amount > 50000}
</conditionExpression>
</sequenceFlow>

Service Task Example

<serviceTask id="creditCheck" name="Credit Check" 
commandName="PerformCreditCheckCommand">
<extensionElements>
<parameter name="clientId">${clientId}</parameter>
<parameter name="loanAmount">${amount}</parameter>
<parameter name="productId">${productId}</parameter>
</extensionElements>
</serviceTask>

Example: Building a Context Loader Reference

async function generateContextLoaderReference() {
const allLoaders = await getContextLoaders({});

console.log('# Context Loader Reference\n');

// Group by category
const byCategory = {};
allLoaders.data.contextLoaders.forEach(loader => {
if (!byCategory[loader.category]) {
byCategory[loader.category] = [];
}
byCategory[loader.category].push(loader);
});

// Generate documentation
for (const [category, loaders] of Object.entries(byCategory)) {
console.log(`\n## ${category}\n`);

loaders.forEach(loader => {
console.log(`### ${loader.type}\n`);
console.log(`**Description**: ${loader.description}\n`);
console.log(`**Entity Type**: ${loader.entityType}\n`);
console.log(`**Required Fields**: ${loader.requiredFields.join(', ')}\n`);
console.log(`**Variables**:\n`);

loader.variables.forEach(v => {
const req = v.required ? ' (required)' : '';
console.log(`- \`${v.name}\` (${v.type})${req}: ${v.description}`);
});

console.log('\n');
});
}
}

Example: Validating Process Definition

async function validateProcessContextLoader(bpmnXml, contextLoaderType) {
// Get loader definition
const loaders = await getContextLoaders({});
const loader = loaders.data.contextLoaders.find(l => l.type === contextLoaderType);

if (!loader) {
throw new Error(`Context loader ${contextLoaderType} not found`);
}

// Extract variables used in BPMN
const usedVariables = extractVariablesFromBpmn(bpmnXml); // Custom parser

// Check if all used variables are available in loader
const availableVars = loader.variables.map(v => v.name);
const unavailable = usedVariables.filter(v => !availableVars.includes(v));

if (unavailable.length > 0) {
console.warn(`⚠️ Variables used in BPMN but not available in ${contextLoaderType}:`);
unavailable.forEach(v => console.warn(` - ${v}`));
} else {
console.log(`✅ All variables validated for ${contextLoaderType}`);
}
}

Best Practices

✅ Do's

  1. Query Before Creating Process

    // Always check available loaders first
    const loaders = await getContextLoaders({ category: "Lending" });
    const loader = loaders.find(l => l.type === "LoanApplicationContext");

    // Then create process
    await createProcessDefinition({
    contextLoaderType: loader.type,
    ...
    });
  2. Use Appropriate Loader for Category

    ✅ Lending processes → LoanApplicationContext
    ✅ Account processes → DepositAccountContext
    ✅ Client processes → ClientContext
  3. Check Required Fields

    const loader = loaders.find(l => l.type === "LoanApplicationContext");
    console.log(`Required: ${loader.requiredFields.join(', ')}`);
    // Output: Required: loanId
  4. Document Available Variables

    <userTask id="approval" name="Approve Loan">
    <documentation>
    Available Variables:
    - ${loanId}: Loan account ID
    - ${amount}: Loan amount
    - ${clientId}: Client ID
    </documentation>
    </userTask>

❌ Don'ts

  1. Don't hardcode context loader types - Query first
  2. Don't use undefined variables in BPMN - Check loader.variables
  3. Don't mix incompatible loaders and triggers
    ❌ contextLoaderType: "LoanApplicationContext" + triggerEvents: ["OnDepositCreation"]
    ✅ contextLoaderType: "LoanApplicationContext" + triggerEvents: ["OnLoanCreation"]


Last Updated: January 6, 2026