setFilter working in preview but not live

Seems pretty basic but it’s not working. Although it was working perfectly for over a year and suddenly… Nope. Shows only my manual filter, not the calculated number.

I’m basically calculating a number to then look up in a content database to display two graphics associated with that number. In short, it’s a progress chart… 0 - 100%

So, I get the total number from one dataset (varTotalObj.total). Use that number to calculate the percentage toward the goal (varTotalPerc). Round that number to a multiple of 5 (varProgChart). Then use that to filter the images lookup in the dataset and display those images. My dataset contains a row for each of 5 increments from 0 to 100 (ie. 0, 5, 10, 15… 90, 95, 100). Each row contains the corresponding image to be displayed.

Works perfectly in preview. Does not work live. My permissions are set to public for the #PRChData which is the dataset for the images.

Thoughts?

import wixData from ‘wix-data’ ;

$w . onReady ( function () {
$w ( ‘#getTotal’ ). onReady ( () => {
let varTotalObj = $w ( “#getTotal” ). getCurrentItem ()
let varTotal = varTotalObj . total
let varTotalPerc = ( varTotal / 4100000 )* 100
let varProgChart = Math . floor ( varTotalPerc / 5 ) * 5
$w ( ‘#TotalRaised’ ). text = Math . round ( varTotalPerc )+ “% RAISED!” ;

        filterProgChart ( varProgChart ); 
    }) 

});

function filterProgChart ( varProgChart ) {
$w ( ‘#PrChData’ ). setFilter ( wixData . filter ()
. eq ( “number” , + varProgChart )
)
}


I’ve created a “default” filter in the dataset settings just so it would be reasonably close until I get this resolved. But started without a manual filter.

If I am understanding correctly - you have made no changes to the code yet your filter stopped working?

If this is correct, you will want to submit an issue to customer care as this may be a bug

Correct. Filter UI is working. Code stopped working, though. I"ll submit the issue to customer care.

2 Likes

Wow - this magically is working now. I didn’t touch anything in the code. I literally tried this live on multiple days throughout almost a week. Published manual overrides to test that the code was not cashed or was running a certain way. It kept defaulting back to the dataset manual filter number. Something corrected itself. I’ll keep an eye on it but at this point it looks like it’s working. Customer Care checked it and was working for them. Still remains a mystery to me but as of now, it’s working agin.

Thank you for the update on this. I’m glad to hear it’s been resolved.

I’m facing the same issue now. I am using a repeater to show some destinations. If a visitor clicks on “View Map” button, the lightbox opens with a map of the place and direction link. It is working perfectly fine while previewing, but not when viewing it live. What can have gone wrong?

let desc ; (global variable)

export function icoOpenMap_click ( event ) {
let $item = $w . at ( event.context );
desc = $item ( ‘#txtTitle’ ). text ;
wixWindow . openLightbox ( ‘ViewMap’ , desc );
}

In the lightbox page:
import wixWindow from ‘wix-window’ ;
import wixData from ‘wix-data’
import wixLocation from ‘wix-location’ ;
let receivedData = wixWindow.lightbox . getContext ();
$w . onReady ( function () {
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. eq ( “title” , receivedData )
);
});