// boomi_script.groovy — the shape of a Boomi Data Process script, runnable outside Boomi. // In Boomi, 'dataContext' is provided for you. Here a tiny stand-in lets you run the // same loop locally: groovy boomi_script.groovy import groovy.json.JsonOutput import groovy.json.JsonSlurper // ---- local stand-in for Boomi's dataContext (not needed inside Boomi) ---- def dataContext = [ docs : ['{"orders":[{"id":1001,"status":"active"},{"id":1002,"status":"cancelled"}]}'], out : [], getDataCount: { -> 1 }, ] dataContext.getStream = { int i -> new ByteArrayInputStream(dataContext.docs[i].getBytes('UTF-8')) } dataContext.getProperties = { int i -> new Properties() } dataContext.storeStream = { InputStream is, Properties p -> dataContext.out << [text: is.getText('UTF-8'), props: p] } // --------------------------------------------------------------------------- // The script itself — paste this part into a Boomi Data Process shape for (int i = 0; i < dataContext.getDataCount(); i++) { Properties props = dataContext.getProperties(i) def json = new JsonSlurper().parse(dataContext.getStream(i), 'UTF-8') json.orders.findAll { it.status == 'active' }.each { order -> Properties p = new Properties() p.putAll(props) p.setProperty('document.dynamic.userdefined.DDP_ORDER_ID', order.id.toString()) String out = JsonOutput.toJson(order) dataContext.storeStream(new ByteArrayInputStream(out.getBytes('UTF-8')), p) } } // Show what Boomi would receive dataContext.out.each { println "${it.text} DDP_ORDER_ID=${it.props.getProperty('document.dynamic.userdefined.DDP_ORDER_ID')}" }