Accessing process properties
You can access Process Property components and dynamic process properties within your map function script. These sample JavaScript and Groovy custom scripting functions accesses a dynamic process property that serves as a counter to track the number of “priority” orders being mapped.
-
Process Property components use
getProcessPropertyandsetProcessProperty. -
Dynamic process properties use
getDynamicProcessPropertyandsetDynamicProcessProperty.
Although you can usually achieve the same result using individual Get Process Property and Set Process Property function steps, sometimes doing it within the script can be less convoluted, especially if you need to get and set multiple properties.
To find the propertyKey for a Process Property component, open the component and check the Key field on the Process Property tab. You can get the componentId from the URL when you open the component. Unlike setDynamicProcessProperty, setProcessProperty does not take a persistent argument. Whether the value persists across process calls is controlled by the Persist checkbox on the Process Property component itself.
JavaScript examples
Process Property component
| Inputs | priorityFlag (Character) |
| Outputs | `` |
load("nashorn:mozilla_compat.js");
// Import the ExecutionUtil class
importClass(com.boomi.execution.ExecutionUtil);
// Replace with the Process Property component's ID (from the component's URL)
componentId = "12345678-abcd-1234-abcd-1234567890ab";
// Replace with the Key from the Process Property component's Process Property tab
propKey = "PRIORITY_COUNT";
// Retrieve current Process Property component value
propValue = ExecutionUtil.getProcessProperty(componentId, propKey);
// Convert string value to int to do math
var intValue = parseInt(propValue);
// Increment value by 1 if priorityFlag is "true"
if (priorityFlag == "true") {
intValue = intValue + 1;
}
// Convert int value back to String before storing in property
propValue = intValue.toString();
// Set the new property value. Persistence is controlled by the Persist checkbox
// on the Process Property component, not by a script parameter.
ExecutionUtil.setProcessProperty(componentId, propKey, propValue);
Dynamic process property
| Inputs | priorityFlag (Character) |
| Outputs | <none> |
Script
load("nashorn:mozilla_compat.js");
// Import the ExecutionUtil class
importClass(com.boomi.execution.ExecutionUtil);
propName = "PRIORITY_COUNT";
// Retrieve current Process Property value
propValue = ExecutionUtil.getDynamicProcessProperty(propName);
// Convert string value to int to do math
var intValue = parseInt(propValue);
// Increment value by 1 if priorityFlag is "true"
if (priorityFlag == "true") {
intValue = intValue + 1;
}
// Convert int value back to String before storing in property
propValue = intValue.toString();
// Set the new property value. The 3rd parameter indicates if the property should be persisted (true) or not (false).
ExecutionUtil.setDynamicProcessProperty(propName, propValue, false);
Groovy examples
Process Property component
| Inputs | priorityFlag (Character) |
| Outputs | `` |
// Import the ExecutionUtil class
// Replace with the Process Property component's ID (from the component's URL)
componentId = "12345678-abcd-1234-abcd-1234567890ab";
// Replace with the Key from the Process Property component's Process Property tab
propKey = "PRIORITY_COUNT";
// Retrieve current Process Property component value
propValue = ExecutionUtil.getProcessProperty(componentId, propKey);
// Convert string value to int to do math
int intValue = Integer.parseInt(propValue);
// Increment value by 1 if priorityFlag is "true"
if (priorityFlag == "true") {
intValue = intValue + 1;
}
// Convert int value back to String before storing in property
propValue = Integer.toString(intValue);
// Set the new property value. Persistence is controlled by the Persist checkbox
// on the Process Property component, not by a script parameter.
ExecutionUtil.setProcessProperty(componentId, propKey, propValue);
Dynamic process property
| Inputs | priorityFlag (Character) |
| Outputs | <none> |
Script
// Import the ExecutionUtil class
import com.boomi.execution.ExecutionUtil;
propName = "PRIORITY_COUNT";
// Retrieve current Process Property value
propValue = ExecutionUtil.getDynamicProcessProperty(propName);
// Convert string value to int to do math
int intValue = Integer.parseInt(propValue);
// Increment value by 1 if priorityFlag is "true"
if (priorityFlag == "true") {
intValue = intValue + 1;
}
// Convert int value back to String before storing in property
propValue = Integer.toString(intValue);
// Set the new property value. The 3rd parameter indicates if the property should be persisted (true) or not (false).
ExecutionUtil.setDynamicProcessProperty(propName, propValue, false);