Skip to content
The first genuine Scripting Solution for Open Text Content Server
PDF

Content Server object

Content Script objects are document-class objects on Content Server.

Content Scripts are restricted objects: as such, users must be enabled to the creation of new objects through the Administration pages.

Content Scripts are executable objects, and the execution is the default action associated to the object.

Being standard objects, Content Scripts comply with Content Server permissions model. Make sure you assigned the proper permissions to your scripts.

Upon creation, the object can be edited with the web-based IDE selecting the 'Editor' function in the object function menu. The function is also available as a promoted function.

Creating a Content Script

To create a new Content Script object you can leverage the standard add item menu: Content Script can be created through the add item menu

Content Script can be created through the add item menu

Object's properties

This section covers the following topics:

  • Content Script Static variables
  • Scheduling a Content Script
  • Running a Content Script as a different user
  • Changing the default GUI icon for a Content Script object

Static variables

For every Content Script, it is possible to define a set of static, precompiled variables whose values will be available when the script is executed.

The framework supports the definition of these variables by means of a second script, whose outcome is the data map containing the values. For performance reasons, this second script is executed only when it changes (or when execution is explicitly forced by an editor), and the results are stored as part of the script object.

One of the reasons for having a script to define a static variable (instead of explicitly setting the value of the variable itself) is code portability: instead of defining the value of a variable, it is possible to define a rule to calculate that value. A typical example would be the Object ID of an object located in a specific position in Content Server: in case the code is moved to a different environment, the ID would be recalculated automatically.

Static variables are accessible within the Content Script through the csvars object.

Each Content Script object has its own csvars constants. In complex applications, that include multiple Content Script objects, it is often useful to have all constants defined in one single file. This can be done by creating a Content Script dedicated to be the “constants” script, that will be run by the single scripts in the application to load the variable values in the context.

Scheduling

Content Script supports the automatic execution of scripts through its internal scheduler.

The Content Script scheduling utility is available from within the Specific > Advanced Settings tab or from the Content Script Editor in the Administration tab (if visible). The utility allows to schedule the automatic execution of Content Scripts (that is, without the need for a user to trigger the execution explicitly).

The scheduling is configured by means of a cron expression. A cron expression is a string comprising a set of fields separated by spaces, and identifies a set of times.

Cron expressions are powerful but can also be quite complex. For this reason, a simplified configurator with drop-down menus can be used to create the desired cron expression.

Skilled users can always flag the “Advanced Mode” checkbox to disable the configurator and compose their own expressions.

Once ready, the scheduler can be enabled by flagging the “Enable Scheduling” checkbox.

It is possible to stop a script from being rescheduled in case of execution errors. To do so, simply flag the “Stop on Error” checkbox.

Where is the log ?

Content Script scheduling takes advantage of the Content Server’s Distributed Agent framework. While normally executing a script will cause it to be run in the current front end server, a scheduled script could actually be executed on any server on which Distributed Agents are activated.

Impersonate

Content Script supports the execution of a script impersonating specific users.

This configuration applies for both:

  • scripts explicitly executed by users

  • scripts executed by the system (scheduled, workflow steps, callbacks, etc…)

The “Run As” configuration panel is accessible within the Specific > Advanced Settings tab or from the Content Script Editor in the Administration tab (if visible).

In order to be able to perform a “Run As” configuration, a user must have impersonation privileges.

Icon Selection

Given the flexible nature of Content Script objects (both in terms of behaviour and execution outcome) it is often useful to be able to distinguish them at-a-glance. One way is to customize the default icon used by Content Server for the object.

The desired icon can be selected by clicking on the icon button on the Content Script's Developer tab and selecting a specific icon within a set of available icons.