Creating a Node.js Script

This topic provides an overview on creating a sample Node.js script for use with a Laserfiche Cloud Script Rule.

  1. Ensure that Node.js is installed on the remote agent host, and that the system variables have been configured to allow "node" or "node.exe" to run command-line Node.js scripts.
  2. Create a .js script file or use our helper script. Inputs in the script can be accessed by:

    process.argv[2] (…) process.argv[n+1]

    which will return the inputs to the script in the format:

    "inputName1=value1" (…) "inputNamen=valuen"

    which can be parsed in your script.

    Outputs from the script should be printed to the standard output in the format:

    "outputName1:value1"

  3. The following is an example of a Node.js script that takes two inputs, combines them, and returns them as a single output value.
  4. const process = require('process');
    				
    let input1 = process.argv[2];
    let idx1 = input1.indexOf('=');
    let inputValue1 = input1.substring(idx1+1);
    				
    let input2 = process.argv[3];
    let idx2 = input2.indexOf('=');
    let inputValue2 = input2.substring(idx2+1);
    				
    var echoinput = function(z1,z2){
    	console.log("outputValue1:"+z1+" "+z2);
    }
    				
    echoinput(inputValue1, inputValue2);
    

Related Links

See the following Laserfiche Github page to download blank script templates for your node.js scripts.