Introduction
A Creatio module is an isolated software unit. It has no information about other Creatio modules apart from the module name list from which is depends. See “Modular development principles in Creatio” for more information about Creatio modules.
Sandbox object is used for interaction between the isolated modules. One of the key sandbox mechanisms is module message exchange.
Modules can only communicate via messages. A module shall publish a message to communicate its status change to other Creatio modules. If the module needs to receive messages about status change in other modules, it must be subscribed to these messages.
To interact with other Creatio modules, the module must import the sandbox module as a dependency.
Message registration
You need to register messages to implement module message exchange.
sandbox.registerMessages(messageConfig) method is used to register module messages, where messageConfig is a module message configuration object.
Configuration object is a “key-value” collection, where every element is as follows:
“MessageName” is a collection element key that contains the message name. The value is a configuration object that contains the following properties:
- mode – message operation mode. Must contain Terrasoft.MessageMode (Terrasoft.core.enums.MessageMode) enumeration value.
- direction – message direction. Must contain Terrasoft.MessageDirectionType (Terrasoft.core.enums.MessageDirectionType) enumeration value.
Message exchange modes (mode property):
- Broadcast – message operation mode with a predefined number of subscribers. Corresponds to Terrasoft.MessageMode.BROADCAST enumeration value.
- Address – message operation mode when a message can only be processed by one subscriber. Corresponds to Terrasoft.MessageMode.PTP. enumeration value.
Message direction (direction property):
- Publication (publish) – the module can only publish a message in sandbox. Corresponds to Terrasoft.MessageDirectionType.PUBLISH. enumeration value.
- Subscription (follow) – the module can only subscribe to a message, published from another module. Corresponds to Terrasoft.MessageDirectionType.SUBSCRIBE. enumeration value.
- Bidirectional – allows to publish and subscribe to the same message in different instances of the same class or within the same schema inheritance hierarchy. Corresponds to Terrasoft.MessageDirectionType.BIDIRECTIONAL. enumeration value.
Module message registration:
To reject message registration in a module, use sandbox.unRegisterMessages(messages) method, where messages – is a message name or a message name array. Message registration rejection:
Adding messages to module schema
You can also register messages by adding them to a module schema or via a designer.
To add messages to module schema:
1. On the Structure tab of the module schema designer select the Messages node, right-click and execute the Add command (Fig.1).

2. Set the necessary properties for the added message (Fig.2):
- [Name] – the message name that corresponds to the module configuration object key.
- [Direction] – message direction. Possible values: “Follow” (subscribe) and “Publish” (publish).
- [Mode] – message operation mode. Possible values: “Broadcast” and “Address”.

Message publication
sandbox.publish(messageName , messageArgs, tags) method is used to publish messages.
Method parameters:
- messageName – the string that contains the message name, for instance, "MessageToSubscribe".
- messageArgs – the object, passed as an argument to the message handler method in the subscription module. If there are no input parameters in the handler method, assign null value to messageArgs parameter.
- tags – tag array that allows to uniquely identify the message sending module. Usually, the [this.sandbox.id] value is used. Sandbox defines the message subscribers and publishers according to the tag array.
Message publication method:
When you publish a message in the address mode, you can receive the result of its processing by the subscriber. To do this, the message handler method in the subscription module must return the corresponding result (see “Message subscription”). Message publication:
When you publish a message in the broadcast mode, you can receive the result of its processing via the object, passed as an argument to the handler method.
Message subscription
You can subscribe to a message using the sandbox.subscribe(messageName, messageHandler, scope, tags) method.
Method parameters:
- messageName – the string that contains the message name, for instance, "MessageToSubscribe".
- messageHandler – the handler method, run upon the message receipt. It can be either an anonymous function or a module method. A parameter, whose value must be passed upon the message publishing via the sandbox.publish() method can be indicated in the method definition.
- Scope – messageHandler handler method execution context.
- tags – tag array that allows to uniquely identify the message sending module. Sandbox defines the message subscribers and publishers according to the tag array.
Message subscription method:
The message handler method must return the corresponding result for a message in the address mode. Message subscription:
Asynchronous message exchange
Use callback function approach if the message handler method in subscription module generates the result asynchronously.
Message publication and result:
Message subscription:
Module with a message:
Below is a module with message publication and subscription: