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

addSingleField(String, Object)
addArrayField(String, Object[])
addSingleDateField(String, Date)
addDateArrayField(String, Date[])
getCreatedDate()
getDocumentLength()
getFileName()
getLastAccessedDate()
getMd5()
getModifiedDate()
getPath()
setFileName(String)
setPath(String)
setModifiedDate(Date)
getDocumentField(String) - Produces a DocumentField object with the following methods. Returns null if the field is not present.
getFieldName()
getFieldValue()
Ex. rd.getDocumentField('myfield').getFieldValue();
isFieldValueArray() - Check if the value of the field is an array
getFieldValueAsArray() - Return the field value as an array of Objects (even single values)
getFieldType() - Return the data type of the field
toJSONObject() - returns a JSON Object containing the keys "name","type","value"
getDocumentFieldWithLowerCase(String) - Case insensitive version of getDocumentField()
getFieldAsStringHolder(String) - Returns a FieldStringValueHolder object with some utility methods for checking field content
isEmpty() - Checks if the field is empty
isArray() - Check if the field has multiple values
getSingleStringValue() - Return the values as a comma delimited list
getArrayValue() - Returns the value as a String array
getVersionInfo() - Produces a VersionInfoBean object. Null if none is present.If retrieving versions from the source repository, the task will process them in order. Setters are available for all the following as well.
getTotalVersions() returns and [integer]
getLabel()
getFileName()
getLastModified() returns a [long] in timestamp format
getFileLength() returns a [long] in bytes
getPath()
isLatest() returns a [boolean]
isMajor() returns a [boolean]
getObjectId
getFieldsMap() - Returns a map of field names and document field objects.
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