URL Logger URLs

Urls grid

Url grid

Url form

Url form

Custom JSON Response

Custom JSON Response

Run Script

Run Script

Command Line

Command Line

Save Files

Save Files

Example

Save Files Example

HTTP Action

Url

Open URL in browser

http://localhost:3333/webhooks/order/234

Url

Execute script option

This option allows custom javascript code execution.

For example this script will execute Advanced ETL Processor package

const execFileSync = require("child_process").execFileSync;
try {
  // This script might hung so always specify a timeout
  const fileToExecute = '"C:\\Program Files (x86)\\DB Software Laboratory\\Advanced ETL Processor Enterprise\\aetlcl.exe"';
  const objectId = 6687;
  const parameters = [objectId];
  const timeout = 60; //seconds
  const stdout = execFileSync(fileToExecute, parameters, { shell: true, timeout: timeout * 1000 });
} catch (e) {
  logger.error(e.message);
  return 500;
}
return 200;

Passing logId to Advanced ETL Processor Enterprise

const fs = require("fs");
const { spawn } = require("child_process");
try {
  const WORKING_DIRECTORY = "C:\\Program Files\\DB Software Laboratory\\Advanced ETL Processor Enterprise\\";
  const fileToExecute = "C:\\Program Files\\DB Software Laboratory\\Advanced ETL Processor Enterprise\\aetlcl.exe";
  const objectId = 8687;
  const parameters = [objectId, logId];
  logger.info(parameters);
  spawn(fileToExecute, parameters, { cwd: WORKING_DIRECTORY, detached: true });
  return 200;
} catch (err) {
  logger.error(`Caught an error: ${err.message ? err.message : err}`);
  return 500; // Any error caught here results in a 500 status
}

Advanced ETL Processor Enterprise Reading logId and saving it into the variable

begin
 SetVariable('<EventId>',CommandLineParameter(2));
 Result:=True;
end;

Executing the Python script without waiting for completion

const fs = require("fs");
const { spawn } = require("child_process");
try {
  const WORKING_DIRECTORY = "C:\\Temp\\";
  // Path to the JSON file
  const jsonFilePath = `${WORKING_DIRECTORY}${logId}.json`;
  const jsonString = JSON.stringify(body, null, 4);
  // Write JSON data to a file
  fs.writeFileSync(jsonFilePath, jsonString, "utf8");
  logger.info(`File written successfully to: ${jsonFilePath}`);
  // Python executable and parameters
  const pythonExecutablePath = `python`; // Use 'python' from PATH
  const parameters = ["test.py", jsonFilePath];
  // Execute the Python script without waiting for completion within specified working directory
  spawn(pythonExecutablePath, parameters, { cwd: WORKING_DIRECTORY, detached: true });
  return 200;
} catch (err) {
  logger.error(`Caught an error: ${err.message ? err.message : err}`);
  return 500; // Any error caught here results in a 500 status
}

Printing webhook data

logger.debug(logId);
logger.debug(method);
logger.debug(originalUrl);
logger.debug(JSON.stringify(body, null, 4));
logger.debug(JSON.stringify(headers, null, 4));
return 200;

Custom response

const data = {
  token: "abc",
  challenge: "123",
  type: "url_verification",
};
res.status(200).json(data);
return -1;

Updating repository tables

const dataSource = require("../../connection");
const rep = dataSource.getRepository("EventLog");
try {
  const record = { char_field_03: "test" };
  rep.update({ id: logId }, record);
  return 200;
} catch (err) {
  logger.error(`Caught an error: ${err.message ? err.message : err}`);
  return 500; // Any error caught here results in a 500 status
}

Confused? Ask question on our ETL Forum

Posted on June 3, 2024 • 3 min read • 467 words
www.etl-tools.com About Support Pricing Cookies Policy Term Of Use Privacy Policy License