PreProcessor, Workflow variables

Posted: 17 August 2009 in checkbox, CSSDK, formAPI, item, Java, Javascript, PreProcessor, radio, select, Teamsite, Worfklow models, Workflows

The workflow preProcessor has access to the workflow variables. For this, we can retrieve the list of global configurable variables and datasources.

/* Configurable variables, Datasource variable and System variables */ 
Iterator<String> workflowParametersIterator = workflow.getParams().keySet().iterator(); 
while (workflowParametersIterator.hasNext()) {
 String parameter = workflowParametersIterator.next();
 System.out.println(parameter + "=" + (String)workflow.getParams().get(parameter));
}
Variable Description
$IW_HOME the installation directory of the current teamsite implementation
$IW_USER the user name of the current user
$IW_AREAOWNER the user name of the owner of the current workarea
$IW_WFNAME the name of the workflow
$IW_SESSION the session id. Very usefull for creating a new client to teamsite, with the same user as the user starting the workflow.
$IW_WORKAREA the name of the current workarea
$IW_FILES the list of attached files
$IW_TIME the current time
$IW_BRANCH the name of the current branch
$IW_STORE the name of the current content store
$IW_SERVER the name of the current teamsite server
IW_PROCESS Indicating the kind of process (PreProcessorCommand)

You can also modify the value of your configurable variables BEFORE the workflow gets started, by adding to the map of keys and values, or modifyinmg specific keys.

workflow.getParams().put("someConfigVar", "someValue");

For select options, create only one variable and use a semi-colon as a separator. On the custom instantiation form, Add some formAPI code to split the value on “;”, loop through the result and add the option to another custom variable. Make the original variable hidden.

The following example retrieves a list of “inline resources” and lets the user decide if they should be included or not by the subsequent workflow:

/* loop through the inline resources (hidden) and add the options for the attached inline resources (visible select) */  
var inlineResourcesToAttachItem = IWDatacapture.getItem("/Config/inlineResourcesToAttach");  
var inlineResourcesValue = IWDatacapture.getItem("/Config/InlineResources").getValue();  
var inlineResources = inlineResourcesValue.split(";");  
for (var inlineResourceIndex in inlineResources){
 /* create a new option to add to the visible inline resources to attach, selected and defaultSelected false by default */
 var option = new Option(inlineResources[inlineResourceIndex],inlineResources[inlineResourceIndex],false, false);
 inlineResourcesToAttachItem.addOption(option);
}

If you need to get connected to teamsite in the preProcessor, you can use the following method:

String sessionString=(String) workflow.getParams().get("$IW_SESSION"); 
String configFilePath = "/apps/interwoven/teamsite/cssdk/cssdk.cfg"; 
Properties localProperties = new Properties(); 
localProperties.setProperty("cssdk.cfg.path", configFilePath); 
CSLocalFactory csLocalFactory = (CSLocalFactory) CSLocalFactory.getFactory(localProperties); 
CSClient client = null; 
try {
 client = csLocalFactory.getClient(sessionString, Locale.ENGLISH, "myPreProcessorNameGoesHere", "localhost"); 
} catch (CSException ex) {
     Logger.getLogger(ComPageDCRInlineResources.class.getName()).log(Level.SEVERE, null, ex); 
}
Advertisements
Comments
  1. Cris says:

    Funny, for a second i thought i get a chance to correct you in this statement “You can also modify the value of your configurable variables BEFORE the workflow gets started,…” then i caught the “BEFORE” all in upper case ;).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s