How to access Dynamic Process Properties using Groovy

Document created by gbockelmann Employee on Nov 8, 2011
Version 1Show Document
  • View in full screen mode
Sometimes you may want to get or set a dynamic Process Property value from within a custom Groovy script to facilitate processing. The example script below shows you how to do so.

Note: The syntax is slightly different for accessing properties from a Process Property component. See this article for more detail.

Example Scenario: In a previous Set Properties step, you have set a Process Property named "MY_COUNT" with a value of "1". Later in the Process you need to access that Process Property from within a Data Process or Map Function custom script to increment the value by 1 and update the property value.
Copy the script below

Notes:
  • Check for null values when getting and setting property values. Attempting to set a null value will result in a RuntimeException.
  • When using in a Map Function context you must select "Groovy". You cannot access properties using JavaScript.

Script:

import com.boomi.execution.ExecutionUtil; 

// Retrieve current Process Property value

propValue =
ExecutionUtil.getDynamicProcessProperty("MY_COUNT");


// Convert string value to int to do math
int intValue = Integer.parseInt(
propValue);


// Increment value by 1
intValue = intValue + 1;

// Convert int value back to String
propValue = Integer.toString(intValue); 

// Set the process property

ExecutionUtil.setDynamicProcessProperty("MY_COUNT", propValue, boolean_variable);

8 people found this helpful

Attachments

    Outcomes