How to define JSON for Pivot table data source, metrics and grouby in UI builder Data Vizualization?

raajesh
ServiceNow Employee
ServiceNow Employee

Hi Team,

 

I am working on the UI builder Data vizualization component and wants to create pivot table. I need to help to define JSON formats for "use script" method to add data sources, metrics and groupby?

 

Can anyone help me around to make JSON format script for pivot table?

 

Thanks

2 REPLIES 2

JagjeetSingh
Kilo Sage
Kilo Sage

Any reason you want to script them?

 

If you want to use different data sources based on certain conditions then you can use multiple data visualization components and then show/hide them based on these conditions.

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

raajesh
ServiceNow Employee
ServiceNow Employee

Hi @JagjeetSingh ,

I am using state variable for dynamic filtering, In data source section in pivot table component, I've passed JSON object in use script , e.g

 

[{
"isDatabaseView": false,
"allowRealTime": true,
"label": "Cost details",
"sourceType": "table",
"tableOrViewName": "<table_name>",
"filterQuery": api.state.filterValue,
"reportSourceSysId": null,
"id": <generated_id>
}];

 

Likewise I've looking for the format of passing groupBy fields in pivot table component.