How to access Dynamic Document Properties using Groovy

Document created by gbockelmann Employee on Nov 8, 2011Last modified by Adam Arrowsmith on May 23, 2018
Version 3Show Document
  • View in full screen mode

Sometimes you may want to get or set a Dynamic Document Property (also known as a "user defined document property" within the scripting context) value from within a custom Groovy script to facilitate processing. The example script below shows you how to do so.

You cannot access Dynamic Document Properties through scripting within a Map Function context. Instead simply use a Get/Set Properties function step in coordination with the scripting step.

  1. Add a Data Process step to your Process.
  2. Add a Custom Scripting step.
  3. Use the following script example to get and set Dynamic Document Properties from within the "document 'for' loop".



import java.util.Properties;

for ( int i = 0; i < dataContext.getDataCount(); i++ ) {
  InputStream is = dataContext.getStream(i);
  Properties props = dataContext.getProperties(i);

  // Retrieve the current property value
  propValue = props.getProperty("document.dynamic.userdefined.MY_PROPERTY_NAME");

  // Modify the value
  propValue = "some new value";

  // Store the new property value
  props.setProperty("document.dynamic.userdefined.MY_PROPERTY_NAME", propValue);

  dataContext.storeStream(is, props);



  • Dynamic Document Properties are prefixed with document.dynamic.userdefined.MY_PROPERTY_NAME.
  • Check for null values when getting and setting property values. Attempting to set a null value will result in a RuntimeException.
13 people found this helpful