Filter to be applied for different data source in UI builder of configurable workspace

Saranya Babu1
Tera Expert

Hello All,

I have created three filter and multiple data visualization and used below client script to merge filter and working perfectly for all the data visualization if the data sources is same table.

 

We want to apply filter for different data sources and its not working

 

function handler({ api, event, helpers, imports }) {

    const mergePARFiltersV2 = imports["global.mergePARFilters"]().v2;
    console.log("mergePARFiltersV2"+mergePARFiltersV2);
    const { appliedFilters } = event.payload;
    console.log("appliedFilters"+appliedFilters);

    api.setState("parFilters", ({ currentValue, api }) => {
        const { parFilters } = mergePARFiltersV2(currentValue, appliedFilters);
        console.log("parFilters"+parFilters);
        return parFilters;
    });
}
When data source is case it working and data source is customer sla view its not working

SaranyaBabu1_2-1715769847034.png

 

SaranyaBabu1_1-1715769203175.png

 

SaranyaBabu1_3-1715770097076.png

 

@Brad Tilton -Will you able to help here?
 
 
 
3 REPLIES 3

Dibyaratnam
Tera Sage

On the Filter component, config properties, there's a Data to filter property where you can add the table name and field for which the filter should apply. check the image below.

DSam1_0-1715791451548.png

 

Mark it as correct if it resolves your issue.

Hello Sam

 

You are awesome. I was struggling for this long time and this helps alot.If its too much to ask.I could really use help once more in a new challenge.

 

I have dropdown for above widget as My work and My team's work.

 

I am using below script to populate data based on drop down selection but its working for CASE table but not working for this CASE SLA table(its a database view)

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 * @Param {any} params.imports
 */
function handler({
    api,
    event,
    helpers,
    imports
}) {
    api.setState('hideContainer', true);
    var prevValue = api.state.prevFilterSelectValue;
    const mywork = "assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe";
    const myteamswork = "assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744";
     const myworksla = "gcase_assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe";
    const myteamsworksla = "gcase_assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744";
    const parFiltersmywork = [{
        "apply_to": ["sn_customerservice_case", "sn_customerservice_case_sla_view"],
        "order": 0,
        "type": "query",
        "encoded_query": mywork,myworksla
    }];

    const parFiltersmyteamswork = [{
        "apply_to": ["sn_customerservice_case", "sn_customerservice_case_sla_view"],
        "order": 0,
        "type": "query",
        "encoded_query": myteamswork,myteamsworksla
    }];
    var x = event.payload.value;
    api.setState('parFilters', parFiltersmywork);
    console.log("Event payload Value" + x);
    if (x === 'mywork' && prevValue !== x) {
        api.setState('hideContainer', true);
        api.setState('prevFilterSelectValue', x);
        api.setState('parFilters', parFiltersmywork);

        var parFiltersmywork1 = JSON.stringify(parFiltersmywork);
        console.log("parFiltersmywork1" + parFiltersmywork1);


    }
    if (x === 'myteamswork' && prevValue !== x) {
        api.setState('hideContainer', false);

        api.setState('prevFilterSelectValue', x);
        api.setState('parFilters', parFiltersmyteamswork);

        var parFiltersmyteamswork1 = JSON.stringify(parFiltersmyteamswork);
        console.log("parFiltersmyteamswork1" + parFiltersmyteamswork1);

    }
}

 

ArslanKZN
Tera Contributor

Hello,

What type of data source you created for Data Visualization to be applied via Filter?

I have the similar requirement: have a filter with instances and couple of Data Visualizations (Vertical Bar and Single Score) to show scan findings as per instance. Currently it is not dynamic. Could you please share with the type of source and code structure?
Thanks!