Retrieving Attributes in a Routing Expression (Get)
You can use the PersistableAdapter API Get method to retrieve attribute values to use in a routing workflow template. The following example retrieves attribute values from a primary business object and uses them in the routing expression of an Or connector node in a routing workflow template.
Description
The PersistableAdapter API retrieves the PBO attribute value to be used in a workflow variable of an assigned activity.
Instructions
The following procedure is used:
1. Add an Or connector node.
2. In the connector properties, specify the following:
a. Under Routing Type, select Conditional.
b. Under the Routing Events field, enter the name of one or more custom events (include multiple entries on separate lines).
c. In the Routing/Tallying Expression field, enter the routing expression code that selects a routing event based on the PBO attribute values. Click Check Syntax to make sure your expression syntax is correct. See the following section for a routing expression code example.
d. Click OK to close the Conditional Properties window.
3. Create an activity node for each routing event.
4. Create a process link for each routing event that links the conditional node to the associated activity node. In the process link properties, specify the Start action next to the applicable routing event under Event in Conditional.
5. End your workflow template as appropriate.
Routing Expression Code Example
In the code example that follows, there are four routing events, based on the values of four PBO attributes. The expression uses the PersistableAdapter API to get the values of PBO attributes. Each value is then turned into a variable which is evaluated in the expression to select a routing event. The following table lists the PBO attribute internal names (as shown in the Type Manager), the variable names, the data types, and the associated routing event for each attribute:
Attribute Internal Name
Workflow Variable Name
Data Type
Associated Routing Event
StringAttribute
stringVar
java.lang.String
StringMatch
BooleanAttribute
booleanVar
boolean
BooleanMatch
DateAttribute
dateVar
java.lang.String
DateMatch
IntegerAttribute
integerVar
int
IntegerMatch
* 
Notice the code in the following example to format the DateAttribute value from a string data type to a date format.
wt.part.WTPart part = (wt.part.WTPart)primaryBusinessObject;
com.ptc.core.lwc.server.PersistableAdapter obj = new
com.ptc.core.lwc.server.PersistableAdapter(part,null,null,null);
obj.load("BooleanAttribute","DateAttribute","IntegerAttribute","StringAttribute");

// Retriving Boolean Attribute
Boolean booleanVar = (boolean)obj.get ("BooleanAttribute");
System.out.println("booleanVar = "+booleanVar);

// Retriving String Attribute
String stringVar = (String) obj.get ("StringAttribute");
System.out.println("stringVar = "+stringVar);

// Retriving Integer Attribute
Long integerVar = new java.lang.Long ((java.lang.Long)obj.get ("IntegerAttribute"));
System.out.println("integerVar = "+integerVar);

// Retriving Date Attribute
java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
java.sql.Timestamp tempDate = (java.sql.Timestamp)obj.get ("DateAttribute");
java.util.Date dateVar = new java.util.Date(tempDate.getTime());
System.out.println("dateVar = "+dateVar);

java.util.Date today = new java.util.Date();
System.out.println("today = "+today );

if (booleanVar)
{
result="BooleanMatch";
System.out.println("result = "+result);
}

else if(today.compareTo(dateVar) == 0)
{
result = "DateMatch";
System.out.println("result = "+result);
}

else if (integerVar == 123)
{
result= "IntegerMatch";
System.out.println("result = "+result);
}

else if (stringVar.equalsIgnoreCase ("test"))
{
result = "StringMatch";
System.out.println("result = "+result);
}
Was this helpful?