Dynamic Property Selections

Provides the developer with the ability to dynamically select fields for the parameter in question that supports this functionality.

Not all API’s support this functionality, those that do are listed below.

API
Aggregate
Distinct (not the simple method)
Join

This functionality exists in an attempt to simplify and manage potential changes in the underlying data schema provided to the relevant API.

If the schema does change, the dynamic field selection functionality can be used to ensure that any and all fields added/removed are catered for regardless of their name or data type.

Syntax

There are four distinct functions available.

FunctionDescription
+FieldType(<Type>)Adds all fields where the type of the field is of the type specified in the parameter.
+FieldType(<FieldName>)Adds all fields where the name of the field is like the name specified as the parameter.
-FieldType(<Type>)Remove all fields where the type of the field is of the type specified in the parameter.
-FieldName(<FieldName>)Removes all fields where the name of the field is like the name specified as the parameter.

More than one function is able to be supplied to a single parameter that supports the functionality. They will fire in order from top to bottom, each time modifying the fields from the call prior.

Parameter values are able to be wildcarded with the % operator in the case where a field name needs to be selected in general and not specifically.

The following example will be used to explain further parts of this documentation.

{
    "aggregationType": "Sum",
    "aggregateBy": [
        "+FieldName(Co%)",
        "-FieldName(ControllingArea)"
    ],
    "aggregateOn": [
        "+FieldType(Double)"
    ],
    "schema": {
        "AmountLC": "Double",
        "AmountGC": "Double"
    },
    "data": [
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6001",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6001",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "1000",
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6001",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2001",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2001",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        },
        {
            "ControllingArea": "0001",
            "CompanyCode": "2000",
            "CostCenter": "CC_2001",
            "GLAccount": "CE_6002",
            "AmountLC": "10.5",
            "AmountGC": "12.8"
        }
    ]
}
Code language: JSON / JSON with Comments (json)

<Type> Parameter

The types supported by the framework are all of those primitive types as outlined below.

  • String
  • Int/Integer
  • Bool/Boolean
  • Date/DateTime
  • Double
  • Float

Examples

In the example above, using the Aggregate API and the aggregateOn parameter, all fields of type Double will be included in the result. This includes:

  • AmountLC
  • AmountGC

Note: Those two properties were introduced to the API as string values. There was a requirement here to explicitly provide the schema parameter and ensure those two properties were cast as Double.

<Name> Parameter

The name parameter has an element of flexibility attached to it. The parameter accepts numerous different field names depending the API being called.

For example, when calling the Join API, there is a possibility that the same field name exists across both data sets that were passed in and those fields are not used to join the datasets on.

If this occurs, you may want to return one field with that name but not the other, therefore, you will need to ensure you only select the field name from the dataset of choice.

Examples

In the example above, using the Aggregate API and the aggregateBy parameter, going from top to bottom:

  • All fields prefixed with “Co are added to the result.
  • The field named ControllingArea is removed. This is specific given no wildcards have been specified.

The resulting selection of the aggregateBy parameter will be properties:

  • CompanyCode
  • CostCenter

As previously stated, depending on the API, you may need to fully qualify the name of the field you wish to include/exclude. The following demonstrates examples of such behaviour.

Name

As per the previous examples, you’re able to specify the name of a property with or without wildcards.

+FieldName(ControllingArea)
+FieldName(Company%)

Fully Qualified Name

This may be required when using the Join API given it expects two datasets as an input.

You can mix and match wildcards to specify properties from a single dataset or multiple. Fully qualifying with square brackets is permitted if the situation requires it.

+FieldName(Header.Company)
+FieldName(Header.Co%)
+FieldName(Header.%)
+FieldName(%.CompanyCode)
+FieldName([LineItems].[CompanyCode])
+FieldName([Line%].[Comp%])