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.

Needing help defining publishMultipleFilter

Taylor Stubbs
Giga Expert
When I'm testing out this Customer Interactive Filter I keep getting an error message within the developer tool of my chrome browner. I thought I had defined publishMultipleFilter but I guess not. Please let me know of any other solutions I can test out. 
Error Message:
$pa_dashboard.do?sys…dgetSideContent:528 Uncaught ReferenceError: publishMultipleFilter is not defined at HTMLInputElement.onchange ($pa_dashboard.do?sys…tSideContent:528:24)

<
?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
 <script>
     var my_dashboardMessageHandler = new DashboardMessageHandler("sys_id");
     var start = ""
     var end = ""
    function publishMultipleFilter() {
        console.log(date,version,start,end)
        if(version=="start"){
        start=date
        } else {end=date}
<!-- Mutliple filters can be passed as an array -->
      var finalFilter = [{"table":"incident","filter":"opened_atONFortnight@javascript&colon;gs.daysAgoStart(440)@javascript&colon;gs.daysAgoEnd(0)"}, {"table":"problem","filter":"opened_atONFortnight@javascript&colon;gs.daysAgoStart(440)@javascript&colon;gs.daysAgoEnd(0)"}];
         <!-- call setDefaultValue first -->
      SNC.canvas.interactiveFilters.setDefaultValue({
my_dashboardMessageHandler._unique_id,
filters: finalFilter,
}, false);
      <!-- then call Publishmessage to publish filters-->
      my_dashboardMessageHandler.publishMessage(finalFilter);
}
    function processDateRange(startDate, endDate) {
    // Base case: if startDate is greater than endDate, stop recursion
        if (endDate >= startDate) {

        // Log the current date in a readable format
        console.log(startDate.toISOString().split('T')[0]);
       
        // Create a new date object to avoid mutating startDate directly
        const nextDate = new Date(startDate);
        nextDate.setDate(startDate.getDate() + 1);
       
        // Recursive call with the next date
        processDateRange(nextDate, endDate);
        }
    }
// Call the function with the desired date range
processDateRange(new Date('2023-01-01').toISOString(), new Date('').toISOString());
   
function clearFilter() {
SNC.canvas.interactiveFilters.removeDefaultValue(my_dashboardMessageHandler._unique_id, false);
my_dashboardMessageHandler.removeFilter();
}
    </script>  
 
<input type="date" id="start" value="" onChange="publishMultipleFilter(this.value,'start')"/>
<input type="date" id="end" onChange="publishMultipleFilter(this.value,'end');"/>  
0 REPLIES 0