Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Data is not visible when click on visualization on widget on workspace

Asha Pathak
Tera Contributor


Hello Community!
I have created one widget for interaction table on service operation workspace

But when we click on visualization section , records are not displayed 

AshaPathak_0-1718623132078.png

This is handled by one client script

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 * @Param {any} params.imports
 * @Param {ApiHelpers} params.helpers
 */
function handler({
    api,
    event,
    helpers,
    imports
}) {
    //set up the variables that need to be defined per component
    var table;
    var title;
    var query;
    var evamId;
    //if the view all button for changes is clicked
    if (event.elementId == "button_bare_1") {
        if (api.state.groupMode) {
            table = "interaction";
            title = "All Interaction";
            query = "active=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744";
            evamId = "2cb49e841b16ce50789a4197dc4bcbd5"; //need to update this later}
        } else {
            table = "interaction";
            title = "All Interaction";
            query = "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe";
            evamId = "2cb49e841b16ce50789a4197dc4bcbd5"; //need to update this later
        }
    }
    //if part of the change donut is clicked
    else if (event.elementId == "donut_2") {
   
        if (api.state.groupMode) {
            table = event.payload.params.table;          
            title = event.payload.data.elements[0]+ " changes";
            query = event.payload.params.query;
            evamId = "2cb49e841b16ce50789a4197dc4bcbd5"; //need to update this later
        } else {
            table = event.payload.params.table;
            title = event.payload.data.elements[0] + " changes";
            query = event.payload.params.query;
            evamId = "2cb49e841b16ce50789a4197dc4bcbd5"; //need to update this later
        }


    }
    //define the currentVizSelection
    const currentVizSelection = {
        "table": table,
        "element": "incident_all",
        "title": title,
        "query": query,
        "evamId": evamId,
        "queryForViewAllRecordCount": query,
        "tableForViewAllRecordCount": table
    }
    //set the state
    api.setState("currentVizSelection", currentVizSelection);
    //this is for the last refreshed on datetime
    api.setState('listRefreshRequested', {
        timestamp: new Date().getTime()
    });
    api.data.get_datetime_now.refresh();
}


I don't undersytand only from where table = event.payload.params.table; this is set
To create widget I have refered below links
https://incident.do/2023/02/21/adding-a-visualization-to-the-overview-section-of-the-servicenow-serv...
https://incident.do/2023/03/14/wiring-a-new-visualization-to-my-work-my-teams-work-dropdown-on-servi...
Please help

0 REPLIES 0