cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Use case: Capturing what the end-user has selected to filter. Then writing back the filtered selection to the app mongodb for further analysis of customer dashboard interaction.
Instructions: Add the code below as a dashboard script.
Notes: Current script will write to the application mongodb leveraging the custom_data api. Update the ajax call to post data to another source.
prism.on('dashboardloaded', function () {
    prism.activeDashboard.$$events.filterschanged.handlers.push(handleEventsChange); console.log(prism.activeDashboard)})
function handleEventsChange(sender, event) {
    var length = event.items.length;
 console.log(event)
 var username = prism.user.userName;    event.items.forEach(curJAQL => {
        if (curJAQL.jaql.filter != null && curJAQL.jaql.filter.exclude != null) {
            var payload = {
                type: 'user-filter-exclude',
    user: username,
                dimension: curJAQL.jaql.dim,
                filterValues: curJAQL.jaql.filter.exclude.members
            }   console.log(payload)            $.ajax({
                url: '/api/v1/custom_data',
                method: 'POST',
                contentType: "application/json",
                data: JSON.stringify(payload)
            })
        } else if (curJAQL.jaql.filter.explicit===true){
   var payload = {
    type:'user-filter-include',
    user: username,
    dimension: curJAQL.jaql.dim,
    filterValues: curJAQL.jaql.filter.members
   }   console.log(payload)    $.ajax({
                url: '/api/v1/custom_data',
                method: 'POST',
                contentType: "application/json",
                data: JSON.stringify(payload)
            })  }        
    });}
Rate this article:
Comments
NT_Sisense_Adm
8 - Cloud Apps
8 - Cloud Apps

HI Thanks for the post really helpful, could see it is not capturing dates in the filters.

Version history
Last update:
‎03-02-2023 09:19 AM
Updated by:
Contributors