Introduction

A brief introduction on user scripts.

Supported languages

  • Ruby
  • JavaScript
  • Python

Configuration

There are two ways to execute user scripts. They can either be submitted directly as a string to the /userScripts or /cases/{caseId}/userScripts endpoints in the script field, or you can place your script in a file in the user scripts directory and invoke them from the same endpoints by specifying the script name in the fileName field.

The user scripts directory is configurable and can be set in the application.properties file.

userScriptsLocation="/Path/To/UserScripts/Directory"

Variables

Each script has several common local variables injected, all of which are available both with and without a leading dollar sign ($):

  • current_case (also as currentCase):This is the Java nuix.Case object. It is only available in the case-specific endpoint /cases/{caseId}/userScripts.

  • utilities: This is the Java nuix.Utilities object for the current environment.

  • request: This is the Java HttpServletRequest object.

  • response: This provides methods for customising the object that is returned from the server. These methods are:

    • setStatus(int httpStatusCode): This sets the HTTP status code.
    • addHeader(String headerName, String headerValue): This adds a header to the actual HTTP response that comes back from the server.
    • setBody(Object body): This sets the payload of the response.
  • progress : This provides methods for updating the progress of the script when run in an asynchronous manner. These methods are:

    • setStatus(String status): This sets an arbitrary status value. This will be reflected in the ‘‘status’’ variable in the AsyncFunctionStatus response.
    • setEstimatedFinalValue(long value)): This sets an estimate for the final progress value. This will be reflected in the ‘‘total’’ variable in the AsyncFunctionStatus response, and will be used as the denominator when calculating percent complete.
    • setCurrentValue(long value): This sets the current progress value. This will be reflected in the ‘‘progress’’ variable in the AsyncFunctionStatus response, and will be used as the numerator when calculating percent complete.
  • custom_arguments (also as customArguments): This is the map of provided custom arguments.