# Groovy to painless transform file

**URL:** <https://discuss.elastic.co/t/groovy-to-painless-transform-file/196584>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [August 23, 2019, 8:42pm UTC](https://discuss.elastic.co/t/groovy-to-painless-transform-file/196584 "2019-08-23T20:42:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganga](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@ganga](https://discuss.elastic.co/u/ganga)\
**Post date:** [August 23, 2019, 8:42pm UTC](https://discuss.elastic.co/t/groovy-to-painless-transform-file/196584/1 "2019-08-23T20:42:03Z")

</div>

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

| **Time** | **User Id** | **Count** |

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [August 25, 2019, 5:03pm UTC](https://discuss.elastic.co/t/groovy-to-painless-transform-file/196584/2 "2019-08-25T17:03:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ganga](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@ganga](https://discuss.elastic.co/u/ganga)\
**Post date:** [August 26, 2019, 1:23pm UTC](https://discuss.elastic.co/t/groovy-to-painless-transform-file/196584/4 "2019-08-26T13:23:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 23, 2019, 1:23pm UTC](https://discuss.elastic.co/t/groovy-to-painless-transform-file/196584/5 "2019-09-23T13:23:58Z")

</div>

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