Script administration

The [fleXive] script administration allows you to create scripts in the script editor and to execute scripts directly in the script console. The scripting language of choice is Groovy, but if JavaSE 6 or higher is used any language supported by the Java Scripting API can be used. Please see the section Scripting Engine for more information about scripting in [fleXive].

The following screen shows the creation of a contact data verification script. You can see the select box for the default script event (1) which can be bound to a script. In this case it is BeforeContentSave.

If the default script event is set to Manual, the script can be executed via the administration UI in the script overview.

Table 9.1. FxScriptEvent list
List of available events
  • Manual
  • BeforeContentSave
  • AfterContentSave
  • BeforeContentCreate
  • AfterContentCreate
  • BeforeContentRemove
  • AfterContentRemove
  • AfterContentLoad
  • AfterContentInitialize
  • PrepareContentCreate
  • PrepareContentSave
  • BeforeDataChangeUpdate
  • AfterDataChangeUpdate
  • BeforeDataChangeDelete
  • AfterDataChangeDelete
  • BeforeDataChangeAdd
  • AfterDataChangeAdd
  • BeforeAssignmentDataCreate
  • AfterAssignmentDataCreate
  • BeforeAssignmentDataSave
  • AfterAssignmentDataSave
  • BeforeAssignmentDataDelete
  • AfterAssignmentDataDelete
  • BinaryPreviewProcess
  • AfterAccountCreate
  • AfterTreeNodeAdded
  • AfterTreeNodeRemoved
  • BeforeTreeNodeRemoved
  • AfterTreeNodeActivated
  • BeforeTreeNodeActivated
  • AfterTreeNodeFolderReplacement

The following screen shows the script overview. You can see the script (1), which can be executed manually via the administration UI, and other scripts, bound to different events.

The following screen shows the [fleXive] Script console. It allows you to execute scripts directly at the EJB layer.

You can choose between the following languages and file extensions (1):

  • gy: Groovy v1.5.1 (Bundled GroovyShell v1.5.1)
  • groovy: Groovy v1.5.1 (Bundled GroovyShell v1.5.1)
  • js: ECMAScript v1.6 (Mozilla Rhino v1.6 release 2)

If you want to execute the script on the web layer, check the option Execute at Web layer (2). Mind that this feature is only available for bundled Groovy!

The Groovy code in this example creates a new tree node in the Edit tree of the Content Tree. The node's name is NodeName and its label NodeLabel.

You might want to copy paste the example and try it out:

import com.flexive.shared.EJBLookup;
import com.flexive.shared.interfaces.TreeEngine;
import com.flexive.shared.tree.FxTreeNodeEdit;
import com.flexive.shared.value.FxString;

//Lookup the tree interface
TreeEngine tree = EJBLookup.getTreeEngine();
//create new node
FxTreeNodeEdit node = FxTreeNodeEdit.createNew("NodeName");
FxString label = new FxString(false, "NodeLabel");
//create the node
long id =;