Groovy to painless transform file

Hi, I have a watcher with the transform and parser files which I need to migrate from groovy to painless but I am getting some error.

The transform file is below which needs to be migrated from groovy to painless, anyone could help in migration is greatly appreciated!!

def op

if ( ipval == "emvipperr" )
{
def bck = ctx.payload.aggregations.dateRange.buckets[0]
op = "

EMV IPP Error Details:

"
op += ""
op += ""
op += ""
bck.timeRange.buckets.each {
k ->
def millis = ky
def timeofOcc = new Date(millis).format("yyyy-MM-dd HH:mm:ss.SSS")
k.user_Id.buckets.each {
ki ->
		op += "<tr><td style='padding:5px;padding-left:20px;padding-right:20px;background-color:#F9F9F9'>${timeofOcc}</td>"
		op += "<td style='padding:5px;padding-left:20px;padding-right:20px;background-color:#F9F9F9'>${ki.key}</td>"
		op += "<td style='padding:5px;padding-left:20px;padding-right:20px;background-color:#F9F9F9'>${ki.doc_count}</td></tr>"
	}
}
op += "</table><br><br><i>This is system generated alert. Please do not reply.</i><div>"

}
return op

TimeUser IdCount

Hey @ganga,
can you please reformat your post using [code][/code] because I cannot read and understand what is the code and what the returned error.
Thanks

The below transform file which is written in groovy needs to be migrated from groovy to painless, any help in migration is appreciated.

def op

if ( ipval == "emvipperr" )
{
def bck = ctx.payload.aggregations.dateRange.buckets[0]
op = "EMV IPP Error Details"
op += "Time"
op += "User"
op += "Count"
bck.timeRange.buckets.each {
k ->
def millis = ky
def timeofOcc = new Date(millis).format("yyyy-MM-dd HH:mm:ss.SSS")
k.user_Id.buckets.each {
ki ->

		op += "<tr><td style='padding:5px;padding-left:20px;padding-right:20px;background-color:#F9F9F9'>${timeofOcc}</td>"
		op += "<td style='padding:5px;padding-left:20px;padding-right:20px;background-color:#F9F9F9'>${ki.key}</td>"
		op += "<td style='padding:5px;padding-left:20px;padding-right:20px;background-color:#F9F9F9'>${ki.doc_count}</td></tr>"
	}
}
op += "</table><br><br><i>This is system generated alert. Please do not reply.</i><div>"

}
return op

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.