Skip to main content

Overview

Two utility objects are available in operation handler scripts. They serve different purposes:

ObjectAccessPurpose
utilInstance variableService access, component persistence, fact creation — any operation that interacts with FlowerDocs Core
RuleUtilStatic class referenceIn-memory component helpers — read/write tags, classes, and statuses without calling FlowerDocs Core services

util is an instance of RuleContextUtil (which extends RuleUtil). Because it is an instance, call its methods as util.methodName(...).

RuleUtil is a static class reference injected by the script engine. Because all its methods are static, call them as RuleUtil.methodName(...).

info

Since RuleContextUtil extends RuleUtil, calling static methods through the util instance (e.g., util.setTagValue(...)) also works in GraalJS. However, the recommended convention is to use RuleUtil for static calls and util for instance calls, to make the intent clear.

Access to services

This object exposes methods for accessing and interacting with the services exposed by FlowerDocs Core:

NameDescription
getDocumentService()Get document management service
getVersionService()Get document version management service
getFolderService()Get folder management service
getTaskService()Get task management service
getVirtualFolderService()Get virtual folder management service
getService(Component component)Get the appropriate management service for the component type

Component persistence

The following methods can be used to persist or transform a component:

MethodsDescription
create(Component component)Create the component and return the one actually created
update(Component component)Modify the component and return the updated version

RuleUtil - Static helpers

RuleUtil methods are static: they operate on objects already in memory without making service calls. Use them to read or modify tag values, class identifiers, and statuses on the component variable.

MethodsDescription
getClassId(Component component)Get component class value otherwise empty
setClassId(Component component, String classId)Set component class
getStatus(Component component)Get component status value
setStatus(Component component, Status status)Set component status value

Usage examples

Reading tags and calling services

// RuleUtil: read tag values in memory (static call)
var clientName = RuleUtil.getTagValue(component, "NomClient");
var classId = RuleUtil.getClassId(component);

// util: call services (instance call)
util.changeClass(component, "NewClass");
util.update(component);

// util: access a service and perform a search
var request = SearchRequestBuilder.init()
.filter(FilterClauseBuilder.and()
.criterion(CriterionBuilder.name("NomClient").operator(Operators.EQUALS_TO)
.type(Types.STRING).value(clientName).build())
.build())
.build();
var response = util.getVirtualFolderService().search(request);