Get and Set DDP’s in Groovy Script

This blog demonstrates how to Get and Set DDP’s in Groovy Script

In this blog, we will see how to get and set dynamic document properties in groovy script and retrieve them in Boomi process.

What is Dynamic Document Property?

These are key/value pairs which can be set at document level. It can be set within certain scope and not in the entire process. The value which is set in Dynamic document property can be used only in one branch. We cannot persist the value in Dynamic Document property. To retrieve a dynamic document property, we must remember its name and type it in the field, function or script that we are using. There is no limit to set Dynamic document Properties.

In this Use Case,

  • We will set two Dynamic Document Properties named as “First” and “Second” in set properties shape with static values as 5 and 1.
  • In Groovy Script, we would fetch the value of these dynamic document properties, will add them and assign the output to a new Dynamic Document Property named “sum” .

Now, let us see the steps to get and set dynamic process property in groovy script and retrieve in Boomi.

Step 1:

Log on to Boomi platform ( with required credentials i.e. Email Address and Password.

Step 2:

Once logged into Boomi platform, we will be able to view Home page.

Step 3:

Now, click on Services followed by Integration. We will see the Build page. Click on New.

Step 4:

Once, clicked on New, we will be able to see three fields i.e. Type, Component Name and Folder.

  • Select Type as process as we are building a process. Component Name and Folder can be given based on your choice (i.e which name to be given and where do we want to create the process). Click on create.

Step 5:

We see that the process gets created with a start shape which is configured with AS2 Shared Server by default.

Step 6:

Select the start shape and choose No Data. Click ok.

Step 7:

Search for Set Properties shape in search pallet. Drag and drop the shape onto process canvas and place it after start shape.

Step 8:

We will now create dynamic document properties in set properties shape.

  • Let us create by selecting the set properties shape and click on + symbol as shown.
  • Choose Dynamic Document Property from drop down.
  • Give the property name as “First” and click ok.
  • Now, we have to set parameter for Dynamic Document Property.  Select Dynamic Document property and choose + on parameters
  • We will have to set Type and static values in parameters. Here, we are selecting Type as Static from drop down and Static Value would be 5. Click ok.
  • After setting the value for Dynamic Document Property, it looks like as follows.
  • Now, let us create second Dynamic Document Property by following the same steps from Step 8. Give name of Dynamic Document Property as “Second” and set the static value to 1.
  •  After setting the values, it looks like as follows.
  • Click ok.

Step 9: To write a Groovy Script, drag and drop Data Process shape onto the process canvas and click ok.

Step 10: Select data process shapeand click +.

  • Choose Process Type as custom scripting from the drop down. Click on edit.

Step 11:

Now, we will be able to see the command prompt as shown in the screenshot.

Step 12:

Now, we are writing a groovy script to get DDP’s which are set in set properties shape and add the values which we have provided as static. The result will be saved in new Dynamic Document Property named as “sum” which is generated.

 NOTE:  DDP refers to Dynamic Document Property in this blog.

  • In the below 2 steps, we get Dynamic Document Properties (i.e. First and Second) which we have set in set properties shape by using props.getProperty() method.

 propValue1 = props.getProperty(“document.dynamic.userdefined.First”);

                                    propValue2 = props.getProperty(“document.dynamic.userdefined.Second”);

  • The DDP’s that are retrieved from set properties shape are stored in propValue1 and propValue2.

We are using Integer.parseInt() methodto convert the values coming from propValue1 and propValue2 into integer and stores it in sum1 and sum2  reference variables.

int sum1 = Integer.parseInt(propValue1);

                          int sum2 = Integer.parseInt(propValue2);

                          int sum = sum1 + sum2;

  • We can set the Dynamic document property by using the method props.setProperty() which takes2 parameters. The first parameter would be the key named as “sum” and the second parameter would be the result of sum1 and sum2 values which are coming from the above step.


  • Add the script in command prompt and click Ok.

Step 13: 

Now, Drag and drop message shape onto process canvas.

  • Select the shape and in message, give it as Value is {1}. Here {1} would be the runtime value which comes DDPsum.             
  • To configure the variable as DDP sum, click on + and select Type as Document Property and click choose and select Dynamic Document Property from drop down.
  • Now, give the property name as sum and click ok.
  • Now, we see that {1} is configured with DDP which is sum generated in script and holds the result. Click Ok.

Step 14:

Drag and drop the stop shape after message shape to indicate the end.

Step 15:

Now, test the process by selecting the atom.

  • We see that the process havebeen executed successfully and have received the output from DDP i.e. sum.
  • Click on view source and we will be able to see the output.

Leave a Reply

Your email address will not be published. Required fields are marked *