<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: NiFi - ExecuteScript for getting max value of a Json array in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235992#M197805</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;  Great, my boss and I are very grateful for your "very specific" help!&lt;/P&gt;&lt;P&gt;One last question concerning the script: The &lt;STRONG&gt;perfect &lt;/STRONG&gt;solution would leave the &lt;STRONG&gt;FF-content unchanged&lt;/STRONG&gt; and &lt;STRONG&gt;deliver the maxOutput as FF-Attribute&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;Tried this but can't find the right syntax:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;flowFile = session.putAttribute(flowFile, 'MAX_geaendertAm_ABAS', ${max.geandertAm_ABAS})&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;</description>
    <pubDate>Thu, 15 Nov 2018 15:05:35 GMT</pubDate>
    <dc:creator>justenji</dc:creator>
    <dc:date>2018-11-15T15:05:35Z</dc:date>
    <item>
      <title>NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235988#M197801</link>
      <description>&lt;P&gt;Hi, as far I have investigated it is &lt;STRONG&gt;not possible&lt;/STRONG&gt; in &lt;STRONG&gt;EvaluateJsonPath&lt;/STRONG&gt; to get the &lt;STRONG&gt;maximum value of an element of an array&lt;/STRONG&gt;. Searched for something like shown in the picture.&lt;/P&gt;&lt;P&gt;Now I'm searching for a &lt;STRONG&gt;solution with ExecuteScript&lt;/STRONG&gt; like mentioned here: &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/57755/apache-nifi-how-to-calculate-sum-or-average-of-val.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://community.hortonworks.com/questions/57755/apache-nifi-how-to-calculate-sum-or-average-of-val.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Because Im not familiar with the script languages are offered I'm looking for an &lt;STRONG&gt;example &lt;/STRONG&gt;to do this.&lt;/P&gt;&lt;P&gt;Found this: &lt;A href="https://community.hortonworks.com/articles/75032/executescript-cookbook-part-1.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://community.hortonworks.com/articles/75032/executescript-cookbook-part-1.html&lt;/A&gt; &lt;/P&gt;&lt;P&gt;But I don't find &lt;STRONG&gt;how to get the max value&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Any help is very appreciated, thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="93258-hwc-jsonmaxvalue.png" style="width: 1608px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/14474i8F51C9BD85A84311/image-size/medium?v=v2&amp;amp;px=400" role="button" title="93258-hwc-jsonmaxvalue.png" alt="93258-hwc-jsonmaxvalue.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 23:42:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235988#M197801</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2019-08-17T23:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235989#M197802</link>
      <description>&lt;P&gt;You can use QueryRecord for this. Ensure your JSONReader's schema has the geaendertAm_ABAS field marked as a timestamp type (not a string), such as:&lt;/P&gt;&lt;PRE&gt;{
 "namespace": "nifi",
 "name": "ABAS",
 "type": "record",
 "fields": [
  {"name": "ID","type": "int"},
  {"name": "geaendertAm_ABAS","type": {"type": "long","logicalType": "timestamp-millis"}}
 ]
}&lt;/PRE&gt;&lt;P&gt;Then you can add a user-defined property (let's call it "max") to QueryRecord with the value&lt;/P&gt;&lt;PRE&gt;SELECT MAX(geaendertAm_ABAS) from FLOWFILE&lt;/PRE&gt;&lt;P&gt;Your JSONRecordSetWriter will need a schema with just the field:&lt;/P&gt;&lt;PRE&gt;{
 "namespace": "nifi",
 "name": "ABAS",
 "type": "record",
 "fields": [
  {"name": "geaendertAm_ABAS","type": {"type": "long","logicalType": "timestamp-millis"}}
 ]
}&lt;/PRE&gt;&lt;P&gt;Once you click the Apply button on QueryRecord, you will be able to create a connection from QueryRecord called "max" and connect it to the next downstream processor.&lt;/P&gt;&lt;P&gt;As an alternative, here is a Groovy script for use in an ExecuteScript processor, note that it is very specific to your input:&lt;/P&gt;&lt;PRE&gt;def flowFile = session.get()
if(!flowFile) return
try {
   flowFile = session.write(flowFile, {inputStream, outputStream -&amp;gt;
      def objList = new groovy.json.JsonSlurper().parse(inputStream)
      def max = objList.max {Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'",it.geaendertAm_ABAS)}
      def maxOutput = "{\"geaendertAm_ABAS\": \"${max.geaendertAm_ABAS}\"}"
      outputStream.write(maxOutput.bytes)
   } as StreamCallback)
   session.transfer(flowFile, REL_SUCCESS)
} catch(e) {
   log.error("Error while determining max", e)
   session.transfer(flowFile, REL_FAILURE)
}&lt;/PRE&gt;&lt;P&gt;If you instead want the max in an attribute, you can use something like:&lt;/P&gt;&lt;PRE&gt;def flowFile = session.get()
if(!flowFile) return
try {
   def inputStream = session.read(flowFile)
   def objList = new groovy.json.JsonSlurper().parse(inputStream)
   def max = objList.max {Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'",it.geaendertAm_ABAS)}
   inputStream.close()
   flowFile = session.putAttribute(flowFile, 'MAX_geaendertAm_ABAS', max.geaendertAm_ABAS.toString())
   session.transfer(flowFile, REL_SUCCESS)
} catch(e) {
   log.error("Error while determining max", e)
   session.transfer(flowFile, REL_FAILURE)
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Nov 2018 22:42:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235989#M197802</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-11-14T22:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235990#M197803</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; &lt;/P&gt;&lt;P&gt; Thanks for your quick response! 
Sorry, but I'm afraid I'm unable to cope with your answer.
Knowing NiFi only for a few weeks, knowing nothing about the configuration of the Controller Services for JsonPathReader/JsonRecordSetWriter and need to solve the described problem. &lt;/P&gt;&lt;P&gt;I was hoping on some script solution like... &lt;/P&gt;&lt;PRE&gt;flowFile = session.get()
if(!flowFile) return 
flowFile = session.putAttribute(flowFile, 'Value_Groovy', (FF_content.geaendertAm_ABAS.max())) 
session.transfer(flowFile, REL_SUCCESS)&lt;/PRE&gt;&lt;P&gt;... where FF_content is an attribute which contains the json.&lt;/P&gt;&lt;P&gt;No solution for "beginners" possible?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 23:09:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235990#M197803</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2018-11-14T23:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235991#M197804</link>
      <description>&lt;P&gt;I updated my answer with a scripting alternative. If you find it useful, please take the time to "Accept" the answer, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 23:31:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235991#M197804</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-11-14T23:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235992#M197805</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;  Great, my boss and I are very grateful for your "very specific" help!&lt;/P&gt;&lt;P&gt;One last question concerning the script: The &lt;STRONG&gt;perfect &lt;/STRONG&gt;solution would leave the &lt;STRONG&gt;FF-content unchanged&lt;/STRONG&gt; and &lt;STRONG&gt;deliver the maxOutput as FF-Attribute&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;Tried this but can't find the right syntax:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;flowFile = session.putAttribute(flowFile, 'MAX_geaendertAm_ABAS', ${max.geandertAm_ABAS})&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 15:05:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235992#M197805</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2018-11-15T15:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235993#M197806</link>
      <description>&lt;P&gt;Yep, just updated the answer with another script that puts the max in an attribute. Cheers!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 23:44:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235993#M197806</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-11-15T23:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235994#M197807</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; &lt;STRONG&gt;Superb, it works perfect!&lt;/STRONG&gt; One day I will try your original solution, sounds interesting. Bye!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 15:13:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235994#M197807</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2018-11-16T15:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235995#M197808</link>
      <description>&lt;P&gt;Thats nice hint on calculating an aggregation like MAX on a single FlowFile.&lt;/P&gt;&lt;P&gt;I wonder if QueryRecord can also performe aggregation on multiple FlowFiles and output just 1 FlowFile with answer ? Imagine ListS3 which can output multiple FlowFiles (1 per new file created since last time) and we would like to know which of these new n inbound which one is the most recent either using s3.modified or even filename itself shall its timestamp format yyyymmdd HH:mm:ss.SSS ?&lt;/P&gt;&lt;P&gt;I wonder how to get the most recent file ?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 01:38:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235995#M197808</guid>
      <dc:creator>emanueol</dc:creator>
      <dc:date>2019-04-13T01:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235996#M197809</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;&lt;/P&gt;&lt;P&gt;following your above solution for returning the max-value in an attribute my script looks like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;def flowFile = session.get()
if(!flowFile) return
try {
&amp;nbsp; &amp;nbsp;def inputStream = session.read(flowFile)
&amp;nbsp; &amp;nbsp;def objList = new groovy.json.JsonSlurper().parse(inputStream)
&amp;nbsp; &amp;nbsp;def max = objList.max {Date.parse("yyyyMMddHHmmss",it.elem_stand)}
&amp;nbsp; &amp;nbsp;inputStream.close()
&amp;nbsp; &amp;nbsp;flowFile = session.putAttribute(flowFile, 'MAX_elem_stand', max.elem_stand.toString())
&amp;nbsp; &amp;nbsp;session.transfer(flowFile, REL_SUCCESS)
} catch(e) {
&amp;nbsp; &amp;nbsp;log.error("Error while determining max", e)
&amp;nbsp; &amp;nbsp;session.transfer(flowFile, REL_FAILURE)
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It worked fine with Json-format:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [{
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"zn": 1,
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"elem_stand": "20190611140623",
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"elem_id": "1086"
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;},
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"zn": 2,
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"elem_stand": "20190624170807",
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"elem_id": "1089"
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} ] &amp;nbsp;&lt;/PRE&gt;&lt;BR /&gt;&lt;P&gt;But now the &lt;STRONG&gt;input format is changed&lt;/STRONG&gt; to:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "name": "Belegart",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "id": "269",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "table": [
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "zn": 1,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "elem_stand": "20190611140623",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "elem_id": "1086"
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "zn": 2,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "elem_stand": "20190624170807",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "elem_id": "1089"
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]
&amp;nbsp; &amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;And I can't find the &lt;STRONG&gt;right syntax to access the elem_stand within the array&lt;/STRONG&gt; for checking max-value.&lt;/P&gt;&lt;P&gt;Please could you tell me how this is possible? Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 15:03:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235996#M197809</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2019-06-26T15:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235997#M197810</link>
      <description>&lt;P&gt;In the script, you're creating a variable `objList` that (for the first input format) points at the top-level array of objects, so you can call max() directly on that array (I think technically it's a List under the hood). In the second input format, objList will be pointing to the top-level object, so you'll need to get the array member `table` out of the object. Update the "def max" line to this:&lt;/P&gt;&lt;PRE&gt;def max = objList.table.max {Date.parse("yyyyMMddHHmmss",it.elem_stand)}&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jun 2019 00:32:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235997#M197810</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2019-06-28T00:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235998#M197811</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; It works! Thank you so much not only for the solution but also for the explanation!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 12:52:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235998#M197811</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2019-07-01T12:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235999#M197812</link>
      <description>&lt;P&gt;Once again I have to get max-value of a date. This time an &lt;STRONG&gt;attribute &lt;/STRONG&gt;holds the JSON to be checked not the FF-content.&lt;/P&gt;&lt;P&gt;This is the content of attribute RESPONSE:&lt;/P&gt;&lt;PRE&gt;[{"id":"(1208)","datbis":"20190630"},{"id":"(1210)","datbis":"20191231"}]&lt;/PRE&gt;&lt;P&gt;With the script of above discussed problem and this information &lt;A href="https://gist.github.com/mattyb149/478864017ec70d76f74f" target="_blank"&gt;https://gist.github.com/mattyb149/478864017ec70d76f74f&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(thanks to &lt;A rel="user" href="https://community.hortonworks.com/users/641/mburgess.html"&gt;@Matt Burgess&lt;/A&gt; ) it was possible to adjust the script for doing the &lt;STRONG&gt;check in the ff-attribute&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Just in case some else has to solve this too here the script:&lt;/P&gt;&lt;PRE&gt;def flowFile = session.get()
if(!flowFile) return
try {
&amp;nbsp; &amp;nbsp;def objList = new groovy.json.JsonSlurper().&lt;STRONG&gt;parseText(flowFile.getAttribute('RESPONSE'))&lt;/STRONG&gt;
&amp;nbsp; &amp;nbsp;def max = objList.max {Date.parse("yyyyMMdd",it.datbis)}
&amp;nbsp; &amp;nbsp;flowFile = session.putAttribute(flowFile, 'MAX_datbis', max.datbis.toString())
&amp;nbsp; &amp;nbsp;session.transfer(flowFile, REL_SUCCESS)
} catch(e) {
&amp;nbsp; &amp;nbsp;log.error("Error while determining max", e)
&amp;nbsp; &amp;nbsp;session.transfer(flowFile, REL_FAILURE)
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 15:35:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/235999#M197812</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2019-08-01T15:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/288356#M213591</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/38301"&gt;@mburgess&lt;/a&gt;&amp;nbsp;Hi Matt, your help is needed urgently.&lt;/P&gt;&lt;P&gt;The script that reads a JSON structure from an attribute and determines the maximum value of the date worked fine.&lt;BR /&gt;I haven't worked on the flow for a while and now it doesn't work anymore.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In the meantime there was only an update from 1.9.2 to 1.10.0. Otherwise everything is as before.&lt;/P&gt;&lt;P&gt;Since I still have no idea about Groovy, I can't fix the error. Please, could you help me again? Thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This is content of attribute RESPONSE&lt;/P&gt;&lt;DIV class="attribute-value"&gt;[ {"id":"(1208)", "datbis":"20190630" }, { "id":"(1210)", "datbis":"20191231" } ]&lt;BR /&gt;&lt;BR /&gt;ERROR&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ExecuteScript[id=e70ffcf5-016f-1000-0000-000063865879] 
Error while determining max: groovy.lang.MissingMethodException: No signature of method: static java.util.Date.parse() is applicable for argument types: (String, String) values: [yyyyMMdd, 20190630]
Possible solutions: parse(java.lang.String), wait(), clone(), any(), grep(), use(java.lang.Class, groovy.lang.Closure)​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 14:29:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/288356#M213591</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2020-01-27T14:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/288358#M213593</link>
      <description>&lt;P&gt;In NiFi 1.10 we updated Groovy to 2.5.0 (&lt;A href="https://issues.apache.org/jira/browse/NIFI-5254" target="_blank" rel="noopener"&gt;NIFI-5254&lt;/A&gt;), which itself moved the &lt;A href="https://www.baeldung.com/groovy-string-to-date" target="_blank" rel="noopener"&gt;date utils out to a module&lt;/A&gt; which is not included with groovy-all by default. Due to an oversight, the new module(s) were not included with the Groovy components, causing your script to break. I have written up &lt;A href="https://issues.apache.org/jira/browse/NIFI-7069" target="_blank" rel="noopener"&gt;NIFI-7069&lt;/A&gt; to track the inclusion of this module going forward. &amp;nbsp;In the meantime the blog post I linked to above explains how to use the Java 8 (not GDK) date/time classes instead, not just as a workaround but as an improvement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:57:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/288358#M213593</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2020-01-27T15:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - ExecuteScript for getting max value of a Json array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/288426#M213632</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/38301"&gt;@mburgess&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matt, thank you so much for your quick response and help.&lt;/P&gt;&lt;P&gt;It took me some time to figure out what you meant... but it works like a charm!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone can use the solution, here it is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;//======================================================================================================
// TEST java LocalDate.parse with groovy max-function  
// FF-Attribute RESPONSE contains [{"id":"(1208)", "datbis":"20180219" }, { "id":"(1210)", "datbis":"20191231" }, { "id":"(1212)", "datbis":"20200128" }]
// FF-Atribute MAX_datbis returns 20200128
//======================================================================================================
import java.time.LocalDate
def flowFile = session.get()
if(!flowFile) return
try {
   def objList = new groovy.json.JsonSlurper().parseText(flowFile.getAttribute('RESPONSE'))
   def max = objList.max {LocalDate.parse(it.datbis,"yyyyMMdd")}   
   flowFile = session.putAttribute(flowFile, 'MAX_datbis', max.datbis.toString())
   session.transfer(flowFile, REL_SUCCESS)
} catch(e) {
   log.error("Error while determining max", e)
   session.transfer(flowFile, REL_FAILURE)
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 10:49:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-ExecuteScript-for-getting-max-value-of-a-Json-array/m-p/288426#M213632</guid>
      <dc:creator>justenji</dc:creator>
      <dc:date>2020-01-28T10:49:13Z</dc:date>
    </item>
  </channel>
</rss>

