IBM FileNet P8, Version 5.2.1            

Creating a Custom Sweep Action

A CmSweepAction object specifies the action handler implementation that processes class instances that are retrieved by a sweep. The following Java™ and C# examples show how to create two CmSweepAction objects: one that references a handler that is implemented with Java and one that references a handler that is implemented with JavaScript.

For the first CmSweepAction object that is created, the handler that is implemented with Java is contained within a code module. The CodeModule object is retrieved and set on the CodeModule property of the CmSweepAction object.

For the second CmSweepAction object that is created, the sweep action handler is implemented in JavaScript and requires that the script is set on the object's ScriptText property.

Java Example

// Create sweep action for Java handler.
CmSweepAction saJava = Factory.CmSweepAction.createInstance(os, "CmSweepAction");

// Get CodeModule object with Java component.
CodeModule cm = Factory.CodeModule.getInstance(os, "CodeModule",
                new Id("{BC1323BB-D66E-4492-ACD3-CD7135B8ABED}") ); 

// Set CodeModule property.
saJava.set_CodeModule(cm);

// Set ProgId property with fully qualified name of handler class.
saJava.set_ProgId("sample.actionhandler.SweepActionHandler");

// Set other properties and save.
saJava.set_DisplayName("Change class with Java handler");
saJava.save(RefreshMode.REFRESH);

// Create sweep action for JavaScript handler.
CmSweepAction saJavascript = Factory.CmSweepAction.createInstance(os, "CmSweepAction");

// Set ProgId property to script type identifier.
saJavascript.set_ProgId("Javascript");

// Call method to read script from a file, and set the script text on the action object.
String inputScript = readScriptText();
saJavascript.set_ScriptText(inputScript);

// Set other properties and save.
saJavascript.set_DisplayName("Change class with JavaScript handler");
saJavascript.save(RefreshMode.NO_REFRESH);

C# Example

// Create a sweep action for Java handler.
ICmSweepAction saJava = Factory.CmSweepAction.CreateInstance(os, "CmSweepAction");

// Get CodeModule object with Java component.
ICodeModule cm = Factory.CodeModule.GetInstance(os, "CodeModule",
                 new Id("{BC1323BB-D66E-4492-ACD3-CD7135B8ABED}") ); 

// Set CodeModule property.
saJava.CodeModule = cm;

// Set ProgId property with fully qualified name of handler class.
saJava.ProgId = "sample.actionhandler.SweepActionHandler";

// Set other properties and save.
saJava.DisplayName = "Change class with Java handler";
saJava.Save(RefreshMode.REFRESH);

// Create sweep action for JavaScript handler.
ICmSweepAction saJavascript = Factory.CmSweepAction.CreateInstance(os, "CmSweepAction");

// Set ProgId property to type of script.
saJavascript.ProgId = "Javascript";

// Call method to read script from a file, and set the script text on the action object.
String inputScript = readScriptText();
saJavascript.ScriptText = inputScript;

// Set other properties and save.
saJavascript.DisplayName = "Change class with JavaScript handler";
saJavascript.Save(RefreshMode.NO_REFRESH);


Last updated: October 2015
customSweeps_snip2.htm

© Copyright IBM Corporation 2015.