Formatting Data for Plotting with UI Builder, details on requests to /api/now/analytics/data

fredrikange
Tera Contributor

I'm working on a data transform and would like some details on how the data should be formatted to plot correctly when define data manually is used in UI Builder request is being sent to api/now/analytics/data, with the configuration defined by the user interface. The payload looks like this:

 

 

{
    "dataConfigurations": [
        {
            "sortBy": "value",
            "sortOrder": "desc",
            "sourceType": "table",
            "metricId": "ZEdGaWJHVjRYelU0T0RjeVgyNWxaV1JwZEY5dVpXVmthWFF4TnpJeE1URTJNamN5TkRJMDE3MjExMTYyNzM1NjQ=",
            "dataCategory": "group",
            "order": 0,
            "filterQuery": "",
            "aggregateBy": 0,
            "tableOrViewName": "x_58872_needit_needit",
            "aggregateFunction": "COUNT",
            "includeChange": false,
            "includeChangePercentage": false,
            "includeGlobalTargets": false,
            "includePersonalTargets": false,
            "includeForecast": false,
            "includeForecastRange": false,
            "includeTrend": false,
            "includeBand": false,
            "includeGapPercentage": false,
            "includeSparkline": false,
            "includeComments": false,
            "includeGlobalThresholds": false,
            "includePersonalThresholds": false,
            "startTime": "P3M",
            "endTime": null,
            "realTime": false
        },
        {
            "sortBy": "value",
            "sortOrder": "desc",
            "sourceType": "table",
            "metricId": "ZEdGaWJHVjRYelU0T0RjeVgyNWxaV1JwZEY5dVpXVmthWFF4TnpJeE1URTJNamN5TkRJMDE3MjExMTYyNzM1NjQ=",
            "dataCategory": "group",
            "order": 1,
            "numberOfGroups": 10,
            "filterQuery": "",
            "aggregateBy": 2,
            "tableOrViewName": "x_58872_needit_needit",
            "aggregateFunction": "COUNT",
            "groupBy": [
                "state"
            ],
            "showOther": false,
            "disableRanges": true,
            "numberOfGroupsBasedOn": "NO_OF_GROUP_BASED_ON_PER_METRIC",
            "includeChange": false,
            "includeChangePercentage": false,
            "includeGlobalTargets": false,
            "includePersonalTargets": false,
            "includeForecast": false,
            "includeForecastRange": false,
            "includeTrend": false,
            "includeBand": false,
            "includeGapPercentage": false,
            "includeSparkline": false,
            "includeComments": false,
            "includeGlobalThresholds": false,
            "includePersonalThresholds": false,
            "startTime": "P3M",
            "endTime": null,
            "realTime": false
        }
    ]
}

 

 

 
And it gives this response, which can be used when defining data manually with slight modifications. 
Response:

 

 

{
    "result": [
        {
            "order": 0,
            "response": {
                "metadata": {
                    "timeZone": "SESSION",
                    "format": {
                        "unitFormat": "{0}"
                    },
                    "dataSourceLabel": "NeedIt",
                    "eventData": {
                        "table": "x_58872_needit_needit"
                    },
                    "aggregateBy": 0
                },
                "data": [
                    [
                        "value"
                    ],
                    [
                        "8"
                    ]
                ]
            }
        },
        {
            "order": 1,
            "response": {
                "metadata": {
                    "timeZone": "SESSION",
                    "format": {
                        "unitFormat": "{0}"
                    },
                    "groupBy": [
                        {
                            "elements": [
                                {
                                    "label": "Requested",
                                    "eventData": {
                                        "query": "state=13",
                                        "querySegments": [
                                            {
                                                "values": [
                                                    "13"
                                                ],
                                                "field": "state"
                                            }
                                        ]
                                    },
                                    "id": "13"
                                },
                                {
                                    "label": "Closed Complete",
                                    "eventData": {
                                        "query": "state=3",
                                        "querySegments": [
                                            {
                                                "values": [
                                                    "3"
                                                ],
                                                "field": "state"
                                            }
                                        ]
                                    },
                                    "id": "3"
                                }
                            ],
                            "label": "State",
                            "id": "state",
                            "fieldType": "integer"
                        }
                    ],
                    "dataSourceLabel": "NeedIt",
                    "eventData": {
                        "table": "x_58872_needit_needit"
                    },
                    "aggregateBy": 2
                },
                "data": [
                    [
                        "state",
                        "value"
                    ],
                    [
                        "13",
                        "7"
                    ],
                    [
                        "3",
                        "1"
                    ]
                ]
            }
        }
    ]
}

 

 

 
Are there any details on this api, can it be used in Server-side scripts?

0 REPLIES 0