Script execution

Respond to an operation by executing a JavaScript script

Principle

This operation manager allows you to react to the execution of an operation by executing a JavaScript script. The JavaScript script is executed using the [Nashorn] engine (/en/documentation/config/core/appendices/nashorn/) embedded in the FlowerDocs Core JVM.

The script is stored as the content of the document used to configure subscription to the execution of an operation.

Variables

The

OperationContext object is supplied through the context variable to provide information related to the context in which the operation is executed.
When an operation is performed on a particular component (see

Component) , it is supplied through a component variable.
When a search is run, the request and the response (if available) are provided using the request (see

SearchRequest) and response (see

SearchResponse) variables respectively.

Utilities

To facilitate their development, an object accessible through the util variable is made available whose exposed methods are listed here.


Creating a folder when creating a document

var folder = ComponentBuilder.folder().classId('Folder').build();
folder.setName("Dossier " + component.getName());
util.getFolderService().create(Lists.newArrayList(folder));
util.getFolderService().addChildren(folder.getId(), Lists.newArrayList(ReferenceBuilder.from(component)), false);


To manually define this operation handler, the com.flower.docs.bpm.core.operation.ScriptOperationHandler identifier can be used as the value of the OperationHandler tag.