How to bind a PA indicator dynamically to Data Visualization component

Aashish
ServiceNow Employee
ServiceNow Employee

I am trying to show a Line Data visualization dynamically when selected from a dopdown. I have the sys_id of the PA Indicator, but I want to bind it to the data visualization component but I'm failing to do so. Can anyone help me in this??

1 REPLY 1

Dibyaratnam
Tera Sage

Hi, To set up PA indicator dynamically, in the data source section inside config, you need to pass script and same for Metric and other sections.

IN data source section, pass below code by replacing with proper values & requirements

return [{
        "allowRealTime": false,
        "allowTotalValue": false,
        "indicatorType": "2",
        "isScriptedIndicator": false,
        "label": "Sample Dynamic Indicator",
        "sourceType": "indicator",
        "uuid": {
            "breakdowns": [{
                "sysId": "breakdownSysId",
                "elementSysIds": [
                    "elementsysid"
                ]
            }],
            "indicator": "indicatorsysid"
        },
        "id": "uniqueId"
    }];

In Metrics section, pass below script.

return [{
        "dataSource": "uniqueIdofDatasourceconfiguredinPrevStep",
        "id": "uniqueMetricId",
        "aggregateIndicator": "",
        "frequency": 10,
        "numberFormat": {
            "customFormat": false
        },
        "axisId": "primary"
    }];

 In trendby pass below script,

return {
        "trendByFrequency": "date",
        "trendByFields": [{
            "field": "anything",
            "metric": "uniquemetricIdcreatedinprevStep"
        }]
    };

 

After all the setup, you should be good to go.

 

Mark this as Helpful / Accept if this solves the question.

 

Mark my answer as