Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Define a method in Groovy evaluator

Hi ,

I am trying to parse field values using the below code in Groovy evaluator for field field1 :

for (record in records) { try {
StringBuilder ret = new StringBuilder(record.value['field1'].length()); for (String word : record.value['field1'].split(" ")) { if (!word.isEmpty()) { ret.append(word.substring(0, 1).toUpperCase()) ret.append(word.substring(1).toLowerCase())} if (!(ret.length()==record.value['field1'].length())) ret.append(" ") }

record.value['field1'] = ret.toString()

output.write(record)

} catch (e) { log.error(e.toString(), e) error.write(record, e.toString()) } }

I want to apply the same code to multiple fields from the incoming data.

Can you please suggest on how to define a method in Groovy evaluator so that we can pass the incoming required fields to the method ??

Define a method in Groovy evaluator

Hi ,

I am trying to parse field values using the below code in Groovy evaluator for field field1 :

for (record in records) {
  try { 
StringBuilder ret = new StringBuilder(record.value['field1'].length()); for (String word : record.value['field1'].split(" ")) { if (!word.isEmpty()) { ret.append(word.substring(0, 1).toUpperCase()) ret.append(word.substring(1).toLowerCase())} if (!(ret.length()==record.value['field1'].length())) ret.append(" ") }

}

    record.value['field1'] = ret.toString()

 output.write(record)

} catch (e) { log.error(e.toString(), e) error.write(record, e.toString()) } }

}

I want to apply the same code to multiple fields from the incoming data.

Can you please suggest on how to define a method in Groovy evaluator so that we can pass the incoming required fields to the method ??