Archive for the ‘Workflows’ Category

Using other types of variables to create new values inside a script variable can be achieved through the use of :

  • $IW_CV(myconfigurablevar), or
  • $IW_DS(mydatasourcevar), or
  • $IW_SCRIPT(myscriptvar)

When an external task is invoked from a workflow, the command is passed additional parameters.

These are:

  • The workflow job ID
  • The workflow task ID
  • The VPAth of the area in which the task is set to execute, as specified by the AREA V PAth property
  • the area relative VPath of each file attached to the task

For example, let’s say we have a little program that just says hello to a specific user to standard output. If the command is specified as follows:

$IW_HOME/iw-perl/bin/iwperl $IW_HOME/custom/bin/ $IW_USER

Then the final program invocation will look like this:

$IW_HOME/iw-perl/bin/iwperl $IW_HOME/custom/bin/ $IW_USER jobid taskid /default/main/acme/WORKAREA/someworkarea file1relativepath file2relativepath ...

Note that in this example, $IW_USER is part of the command property of the task and is not added by the system.

Datasources allow mainly to select things from drop-down lists in forms publisher forms and workflow forms.

Datasources are nothing but java classes that get executed when a form loads. The class must implement one of the following interfaces:


As part of the implementation, the class must therefore have an execute method which gets passed a DataSourceContext object. The return value and type vary depending of which datasource class you implement.

A SimpleDataSource implementation returns a single value. Forms publisher will use the value for example in a text field.

public String execute(String sessionId, String context, Map params) {
String datasource="value";

A ListDataSource implementation will return a List of strings. Forms publisher will use the same value for the form’s value and label.

public List<String> execute(DataSourceContext context) {
List<String> datasource = new ArrayList<String>();

The context contains some information about the session id, the server context (the vpath of the current node) and the other custom parameters passed to the datasource.

A MapDataSource implementation will return map of strings. Forms publisher will use one value for the label and the other for the value. The key is the value string.

public Map<String, String> execute(DataSourceContext context) {
Map<String,String> datasource = new HashMap<String,String>();
datasource.put("value","label"); // make sure you convert numbers to proper strings

The SortedMapDataSource implementation returns the same as a MapDataSource, except Forms Publisher will sort the results alphabetically.

public Map<String, String> execute(DataSourceContext context) {
Map<String, String> datasource = new HashMap<String, String>();
datasource.put("value", "label"); // make sure you convert numbers to proper strings
return (datasource);

In order to create a new datasource, we need to edit the local/config/DataSourceConfig.xml file. This file is an XML document which defines which datasources are available to the system as a whole.

For the example that follows, we will create a datasource that will allow a user to select an edition from the current branch. We need to add our datasource to the list by adding the following:

<name>Main Branch Editions</name>
<param name="branch">/default/main</param>

We will build a class with that name as follows:

package com.acme.util;

import com.interwoven.cssdk.factory.CSLocalFactory;
import com.interwoven.cssdk.filesys.CSBranch;
import com.interwoven.cssdk.filesys.CSEdition;
import com.interwoven.cssdk.filesys.CSVPath;
import com.interwoven.datasource.core.DataSourceContext;
import com.interwoven.datasource.SortedValuesMapDataSource;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class BranchEditionsDataSource implements SortedValuesMapDataSource {

 public Map<String, String> execute(DataSourceContext context) {
 Map<String, String> parameters = context.getAllParameters();
 Map<String, String> datasource = new HashMap<String, String>();
 String sessionString = context.getSessionId();
 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, "BranchEditionsDataSource", "localhost");
 if (client != null) {
 String branchParameter = parameters.get("branch");
 CSVPath branchVPath = null;
 if (branchParameter != null) {
 branchVPath = new CSVPath(branchParameter);
 } else {
 branchVPath = new CSVPath(context.getServerContext());
 if (branchVPath != null) {
 branchVPath = branchVPath.getBranch(); // make sure we have a branch, really...
 CSBranch branch = client.getBranch(branchVPath, true);
 if (branch != null) {
 CSEdition[] editions = branch.getEditions(true, false, -1);
 for (CSEdition edition : editions) {
 datasource.put(edition.getVPath().toString(), edition.getName() + " - " +                                             edition.getDescription());
 } else {
 throw new NullPointerException("branch is null");
 } else {
 throw new NullPointerException("branch vpath is null");
 } else {
 throw new NullPointerException("client is null");
 } catch (Exception ex) {
 datasource = new HashMap<String, String>();
 datasource.put("error", "An error occured. Please contact your administrator");
 Logger.getLogger(BranchEditionsDataSource.class.getName()).log(Level.SEVERE, null, ex);

 return (datasource);

The context gives you all you need to connect to the local Teamsite server using the session id. From there, we can either grab the editions of the branch passed as a parameter or the current branch. You can also extend


This will give you the ability to grab the client with a simple method call of:

CSClient client=getClient(context);

You will have to use the parameters that the class expects to make the connection:

<param name="servername">teamsite</param>
<param name="csFactory">com.interwoven.cssdk.factory.CSLocalFactory</param>

Once the class has been compiled into the toolkit, we can then tell out formspublisher item to use it.

we can use a “inline” element, with a Datasource “pseudo-command” (note that this is case sensitive). This works for text instances and select, radio and checkbox instances.

    <inline command="Datasource:executeComponent:Main Branch Editions" />

All you now need to do is check the work in the form’s drop down list..

The workflow modeler will “Save to Server” in a workarea that is pre-configured by default to be “/iwadmin/main/workflowModels/iw-wa” in the Teamsite server. The location can be changed in the properties file for the workflow modeler itself in ApplicationSettings.cfg located in the resources folder of the workflow modeler application on the client machine.

The following settings can be used to modify the target workarea:

  • STORE_NAME=iwadmin
  • BRANCH_NAME=main/workflowModels

Once the settings have been changed, restart the workflow modeler.

configurable variables are accessible through “$IW_CV(myconfigurablevar)” type of variables. I had forgotten how that worked and couldn’t access the configurable variable I was after… Doh! This is specially useful in conditional links.

While I’m at it, Script variables can also be accessed through a similar system of “$IW_SV(myscriptvar)”. (to be verified – lol)