JavaScript Processing

This task is a custom operation that allows the user to ask 3Sixty to do things that are not already available in the software. 3Sixty's JavaScript Task allows you to run JavaScript against a repository document during processing. The task uses the ECMA 5.1 specification to execute the JavaScript against the native Java API. Currently, only one root object is exposed called rd (repository document). Any method that can be called against the repository document can be called using JavaScript syntax.


Configuration

To use this task go to the task tab in your job. Select the task from the drop down and click the plus circle to configure the task. Click done after making any changes to save.

Condition check

It will execute the task when the condition's result is 'true', 't', 'on', '1', or 'yes' (case-insensitive), or run on all conditions if left empty. This condition is evaluated for each document, determining whether the task should be executed based on the specified values.

Example: If I only want to run this task for PDF documents I would use the expression: equals('#{rd.mimetype}',"application/pdf")

JavaScript Code

Enter the JavaScript you would like to run while processing the job.

Fields that are also available:

Variable Name : Variable

The Job ID : jobId

The Job Run ID : jobRunId

The variable result is automatically declared in each run of the JavaScript task, and its return value can be used to control which documents continue processing.

Caution:  
The task only supports single quotes for strings. Double quotes will cause errors due to how the content of the script is saved to the database.
When creating the database table name please note that it must be all lowercase.


Methods

Below is an example script to remove fields with empty values:

var map = rd.getFieldsMap();

for(i in map){

var val = map[i].getFieldValue()[0];

 

if(typeof val === 'undefined' || val === ''){

rd.removeField(i);

}

}


Examples

Below is an example of failing and skipping documents based on their content type.

Return Value : Status

'c' : Pass

'f' : Fail

's' : Skip


API Keys

Processor: javaScriptExecutorTask

Key

Display Name

Type

use_condition Check a condition before executing this task. Boolean

task_condition

Condition

String

task_stop_proc

Stop Processing

Boolean

field_javascript

JavaScript Code

String


Related Articles

Elastic Search Connector

MongoDB Connector