We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to group records by a certain field when a widget is clicked on in EA Workspace

matthew_hughes
Kilo Sage

In ServiceNow, I'm working on the below widgets:

matthew_hughes_0-1782976409210.png

At the moment, when I click on any of the 4 bottom widgets, the numbers are shown based on the field they are grouped by. However, when I click on any of the widgets, they open all of the records from that table. The widgets are based on a database view.

 

I was just wondering if anyone knows how I can update the widgets so that if a user clicks on any of them, they open the actual number of records reflected on the widget?

 

1 ACCEPTED SOLUTION

I've found the answer I'm looking for. I applied the following code for event tracker:

 

 

/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {

var query = event.payload.params.query || "";

query += "^GROUPBYspm_u_parent";

return {
route: "list",
fields: {
listTitle: event.payload.title,
table: event.payload.params.table
},
params: {
listView: "Business_Application",
query: query
},
redirect: null,
passiveNavigation: null,
title: event.payload.title,
multiInstField: null,
targetRoute: null,
external: null,
navigationOptions: null
};
}

View solution in original post

2 REPLIES 2

glideFather
Tera Patron

ahoy @matthew_hughes,

 

those are not widgets, but rather reports (data visualisation), no?

 

So you are saying that if you click on "Key Software model: 35" it redirects you to the table and display all the records rather than the 35?


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

I've found the answer I'm looking for. I applied the following code for event tracker:

 

 

/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {

var query = event.payload.params.query || "";

query += "^GROUPBYspm_u_parent";

return {
route: "list",
fields: {
listTitle: event.payload.title,
table: event.payload.params.table
},
params: {
listView: "Business_Application",
query: query
},
redirect: null,
passiveNavigation: null,
title: event.payload.title,
multiInstField: null,
targetRoute: null,
external: null,
navigationOptions: null
};
}