How to get the document count and set it as a process property

Document created by mike_c_frazier Employee on Nov 16, 2015Last modified by Adam Arrowsmith on Mar 22, 2016
Version 3Show Document
  • View in full screen mode

Here is how to store the current number of documents in a dynamic process property named "DOC_COUNT" without affecting the contents of the documents. Note that you still need to iterate through the documents to store them to the outgoing dataContext to pass to the next process step. If you omitted this step, there would be no documents to pass to the next step.

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

ExecutionUtil.setDynamicProcessProperty("DOC_COUNT", String.valueOf(dataContext.getDataCount()), false);

// Leave the rest of the script as-is...
for ( int i = 0; i < dataContext.getDataCount(); i++ ) {
   InputStream is = dataContext.getStream(i);
   Properties props = dataContext.getProperties(i);

  dataContext.storeStream(is, props);
13 people found this helpful