The CreatorCon Call for Content is officially open! Get started here.

Heatmap Visualization - Event handler in Ui Builder

dhivyalaksh
Tera Contributor

I have created a heatmap in ui builder .

when i clicked a cell in the heatmap, its not redirecting to the record page.

dhivyalaksh_0-1758123913217.png

 this the script i have used

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 * @Param {any} params.imports
 * @Param {ApiHelpers} params.helpers
 */

async function handler({
    api,
    event,
    helpers,
    imports
}) {
    const title = event.payload.title;
    var queryObj = event.payload.params.url;
    // converting the following query
    // "sn_risk_risk_list.do?sysparm_query=impact%3De1d1c772d7030200bbc783e80e610364%5Elikelihood%3Dfc318772d7030200bbc783e80e6103d8"
    // to
    // impact=e1d1c772d7030200bbc783e80e610364^likelihood=fc318772d7030200bbc783e80e6103d8
    queryObj = queryObj.split("sysparm_query=").pop();
    queryObj = queryObj.replaceAll("%3D", "=");
    queryObj = queryObj.replaceAll("%5E", "^");
   
    const listTitle = await helpers.translate("Risks");
    queryObj = queryObj + "^state!=retired";
    const payload = {
        fields: {
            "table": "sn_risk_risk"
        },
        params: {
            "query": queryObj,
            "listTitle": listTitle
        },
        title,
        route: "simplelist"


    };
    api.emit("NAV_ITEM_SELECTED", payload);
}
1 REPLY 1

aneta_koleva
Tera Expert

you are not passing a sys_id to your payload, in order the record page to display a record you need to pass a sys_id.

in order to check where exactly the sys_id is stored on the payload of the event and then map it to the fields properties you can simply print the event of the visualization clicked like

console.log("my event", event);
Mark my answer Helpful in case you find it as such.