JavaScript Task


A JavasScript task executes JavaScript code using our JavaScript API.


Creating a new JavaScript task

Right-click the name of the parent Action the new task will be created in, and select Add New Task –> Execute JavaScript Task.

Create JavaScript Task

A new Task appears under the parent Action. Edit the task name as needed. Drag and drop to change the task order.


Configurating a JavaScript task

Any valid JavaScript can be executed in this task. Simply add the code you wish to execute to the code textbox in the configuration tab. You can also use our JavaScript API to manipulate Caristix-related resources.

To return a result for validation, use the callback() method. The callback() method takes a string as an argument and sets the value returned by the task when called.

The following is an example of a JavaScript task’s code. In the example, a GET request is sent to a public FHIR server, and the resulting bundle is returned for validation.

//Create an HTTP request using the provided HTTP GET method and full resource url,
var request = HTTP.create('GET', '');

//Add the Accept header with the value application/fhir+json to the request.
request.setHeader('Accept', 'application/fhir+json');

//Send the HTTP request.
var result = request.send();

//Obtain the HTTP result's body - a Bundle of Patient Resources.
var body = result.body;

//Return the body.