AnsweredAssumed Answered

How to access current data values in custom scripting for loop?

Question asked by jtran821628 on Sep 7, 2018
Latest reply on Sep 10, 2018 by jtran821628

I looked all over the forums but wasn't able to find an example of how to do this.  Here is what I would like to do.

 

Let say I have the 1 flat file document with 5 records like below.

 

1, A

2, B

3, C

4, D

5, E

 

I want to use custom scripting to loop through these 5 records to get the values in column 2 of A-E, and set them to 5 different dynamic process properties (DPP_1 through DPP_5).  Here is the pseudo code for that.

 

import java.util.Properties;
import java.io.InputStream;
import com.boomi.execution.ExecutionUtil;

 

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

 

   propValue = props.getProperty("Get Value of Column 2 for records 1-5 here");

 

   ExecutionUtil.setDynamicProcessProperty("DPP_" + i.toString(), propValue, false);

 

 

   dataContext.storeStream(is, props);

}

 

Where I'm getting stuck is I don't know how to access column 2 that contains A-E in the Groovy for loop.  Can anyone tell me how to do that? 

 

I know you can do this via the set properties shape, but I need to do this for 20+ records, so it would be a lot cleaner to do it in this for loop then go through and manually set 20+ properties in the set properties shape.  This also allows for variable lengths, meaning some documents could have 5 records, while others could have 2, 10 or whatever.

Outcomes