You can quickly set up your first change preprocessor by
completing this procedure. The change preprocessor that is described
in this procedure sets the Creator property to "CP Test" when
a new document is created in the object store.
About this task
By completing the steps described in this procedure, you
create the items identified in the following table.
Item |
Name |
Description |
Document subclass |
CP Test Document |
The class where you assign the change preprocessor definition.
The change preprocessor action is run on all documents that are created
with this class definition. |
Change preprocessor definition |
CP Test Definition |
Associates a change preprocessor action with the CP Test Document
class. |
Change preprocessor action |
CP Test Action |
Contains the JavaScript code
that performs the action. |
Object store folder |
CP Test Folder |
The folder where you can add documents when you test the change
preprocessor. |
Procedure
To set up a change preprocessor:
- Set object store security so that you have access rights
to modify the Creator system property. (Full Control access does not
include the required access rights by default.)
- In the administration console, right-click the object
store where you want to create the change preprocessor and click the Security tab.
- Select your user name.
- Edit your permissions and select Modify certain
system properties.
- Create a subclass of Document.
- Navigate to .
- Right-click Document Class and
click New Class.
- Complete the Create a Class wizard by using the following
values:
- Name: CP Test Document
- Symbolic Name: CPTestDocument
- Description: Document subclass for testing change preprocessors.
You can use the default values for the remaining items.
- Create a change preprocessor definition and a change preprocessor
action.
- Double-click the CP Test Document class
that you created and click the Change Preprocessor Definitions tab.
- Select Show Inherited to show
inherited change preprocessor definitions.
- Click New and enter the following
values:
- Display Name: CP Test Definition
- Status: Select to enable the change preprocessor definition.
- Action: Select a change preprocessor action.
- Right-click the Change Preprocessor Actions folder.
- Click New Change Preprocessor Action and
complete the Create a Change Preprocessor Action wizard by using the
following values:
- Name: CP Test Action
- Description: This action sets the Creator property to "CP Test" when
a new document is added to the system.
- JavaScript: Select
the JavaScript radio button
and enter the following script where prompted:
// Set Creator property to "CP Test" when a new document is created.
importClass(Packages.com.filenet.api.action.Create);
function preprocessObjectChange (sourceObj)
{
// Verify that the pending action is a create action.
var actions = sourceObj.getPendingActions();
for ( var i = 0; i < actions.length; i++ )
{
if ( actions[i] instanceof Create )
{
// Set Creator property to "CP Test"
sourceObj.getProperties().putValue("Creator", "CP Test");
return true;
}
}
return false;
}
- Click Add as New and then click OK.
- Prepare to test the change preprocessor.
- Navigate to .
- Right-click Root Folder and click New
Sub Folder.
- Enter CP Test Folder and click Create.
- Test your change preprocessor.
- Right-click CP Test Folder and
click New Document.
- Complete the New Document wizard by using the following
values. If a field or selection is not specified, use the default
value.
- Document Title: CP Test 1
- Without Content: Select this radio button.
- Class: Choose CP Test Document from the
list.
- After you have specified the document class, click Create.
- Check the document properties and verify that the Creator
property is set to CP Test.
- Optional: Do one or more of the following tasks: