Batch Processor
Headless Client Plugin Guide / Batch Processor
Overview
Features
Examples
Bind to a startup method
/**
* Callback method for when solution is opened.
*
* @param {String} arg startup argument part of the deeplink url with which the Client was started
* @param {Object<Array<String>|String>} queryParams all query parameters of the deeplink url with which the Client was started, key>string if there was one value else key>Array<String>
*
* @properties={typeid:24,uuid:"E4E0B0D5-B12B-40B1-8E4B-CC5670C9C5D2"}
*/
function onSolutionOpen(arg, queryParams) {
// Example: Initializing system-wide settings
application.output('Batch Processor: Server has started. Initializing system...');
// Perform any server-side maintenance or setup
performMaintenance();
}
function performMaintenance() {
// Maintenance logic
// You could perform database cleanups, data synchronization, etc.
application.output('Batch Processor: Starting maintenance tasks...');
// 1. Clean up old server logs (keeping only the last 3 months)
var cutoffDate = new Date();
cutoffDate.setMonth(cutoffDate.getMonth() - 3); // Logs older than 3 months
var logQuery = databaseManager.createSelect('db:/example_db/log_table');
logQuery.where.add(logQuery.columns.log_date.lt(cutoffDate));
// Delete old log entries
var deletedLogs = databaseManager.getFoundSet(logQuery).deleteAllRecords();
application.output('Batch Processor: ' + deletedLogs + ' old log records deleted.');
// 2. Remove outdated session data (keeping only the last 7 days)
var sessionCutoffDate = new Date();
sessionCutoffDate.setDate(sessionCutoffDate.getDate() - 7); // Sessions older than 7 days
var sessionQuery = databaseManager.createSelect('db:/example_db/session_table');
sessionQuery.where.add(sessionQuery.columns.session_date.lt(sessionCutoffDate));
// Delete old session entries
var deletedSessions = databaseManager.getFoundSet(sessionQuery).deleteAllRecords();
application.output('Batch Processor: ' + deletedSessions + ' old session records deleted.');
application.output('Batch Processor: Maintenance tasks completed.');
}Run once and shutdown
Schedule a recurring task
Last updated
Was this helpful?