Aggregation Arrays

An aggregation consists of the following three arrays of objects:

aggregations Array

An array of columns with their associated aggregation type.

groupBy Array

An array of columns to group by.

Starting with API 1.4.2 and EnterpriseOne Tools 9.2.1, if grouping by a date field, you have the following additional options:

  • Use the specialHandling field of the column in the groupBy array to indicate desired date formatting for the date groups. Possible specialHandling values are:

    • "User" – Uses the EnterpriseOne user's preferred date format.

    • "CALQTR" – Uses the four digit year and two digit month format, for example 2016-10.

    • SimpleDateFormat - Uses the simple date format that you supply, such as yyyy-MM-dd. Refer to the following Java documentation for the types of date format strings:

      https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

  • Use APIs to create group by requests with these values:

    //add a group by for users date preferenceaggregation.addAggregationGroupBy("F4211", "DRQJ",AggregationInfo.DATE_USER_FORMATED)

    //OR add a group by with SimpleDateFormatSimpleDateFormat sdf = newSimpleDateFormat("yyyy-MM-dd"); aggregation.addAggregationGroupBy("F4211", "DRQJ",sdf);

By default, the output of date groups is milliseconds.

The following code is an example of JSON for an aggregation object with a special date format used for groupBy:

"aggregation" : {
    "aggregations" : [ {
      "column" : "UPRC",
      "aggregation" : "SUM"
    }, {
      "column" : "*",
      "aggregation" : "COUNT"
    } ],
    "groupBy" : [ {
      "column" : "F4211.DRQJ",
      "specialHandling" : "yyyy-MM-dd"
    } ],
    "orderBy" : [ {
      "column" : "F4111.DRQJ",
      "direction" : "ASC"
    } ]
  }

orderBy array

An array of columns to order by with the direction. There are two possible directions to order by:

  • Ascending, which uses the following constant:

    OrderByDirection.ORDER_DIRECT_ASCENDING()

  • Descending, which uses the following constant:

    OrderByDirection.ORDER_DIRECT_DESCENDING()

You can also order by an aggregation result.