I have my Wix Events collection connected to 3 text elements on the page to display the next scheduled event. I want #watchSessionButton to show when the event is live.
I tried to use the info above with the getCurrentItem API to make this happen but it’s not working. I’m sure I’ve done this completely wrong but not sure where to go from here.
Any help would be appreciated!
$w.onReady(function () {
//TODO: write your page related code here...
$w("#eventsDataset").onReady(() => {
let itemObj = $w("#eventsDataset").getCurrentItem();
let eventStart = itemObj.start();
let eventEnd = itemObj.end();
const today = new Date();
if (eventStart <= today && eventEnd >= today ) {
$w("#artistSignupButton").hide();
$w("#watchSessionButton").show();
}
});
});
Hi Lmarie 
Try this instead:
if (eventStart.getTime() <= today.getTime() && eventEnd.getTime() >= today ) {
$w("#artistSignupButton").hide();
$w("#watchSessionButton").show();
}
Ahmad
I’ve just given that a go but still not working. I’ve just noticed that I’m getting the following error in preview:
" An error occurred in one of datasetReady callbacks TypeError: itemObj.start is not a function "
This is an error in another part of your site, please provide your page URL so we can investigate.
Ahh okay, here’s the URL: https://lm1223.editorx.io/responsi ve /home
Thank you!
Whilst on the topic… I’m also struggling a little with the dataset filters. I had the filter set as Status is SCHEDULED and that worked fine, but then realised it needs to be filtered to status is SCHEDULED or STARTED .
So I added a second filter for STARTED and now it doesn’t seem to be connecting to the dataset at all. This is obviously because it wont see any item to match both these conditions at the same time.
Is there a way to add a filter that allows the value to be multiple options?
The error is because of these lines (11 & 12):
let eventStart = itemObj.start();
let eventEnd = itemObj.end();
What you’re doing is assigning the “eventStart” value a function “start()”,
when you add () to a word, it’ll become a function call, and obviously, you don’t have functions called “start()” and “end”, that’s why you’re getting an error.
What you want to do is accessing the values themselves:
let eventStart = itemObj.start;
let eventEnd = itemObj.end;
Note that the “start()” and “end” methods don’t have the () anymore.
Correct these lines and hopefully everything will be fine.
Ahmad
Simple as that haha! This is the thing with trying to get by copying APIs. Hopefully, I’ll get there in time after using the Javascript course. Just trying to get this site up and functioning asap so I feel I need to try and piece it together for the moment.
Thanks again for your help. Really appreciate it.
You need a multiple-choice-filter?
Yup
Simple as that!
You’re welcome, glad that I helped!
Take a look at my comment (example) here:
https://www.wix.com/corvid/forum/main/comment/5ef32197c807e2003451b601
There’s another example in my comment as well.
If your question is answered, please mark it as answered.
Thank you, I’ll check that out 
So, everything was working great and then all of a sudden on the next test the code doesn’t seem to be running properly…
I am not getting an error messages but on loading the preview and the live site after creating a current event to test the code, it’s just not working.
The data filter is working and it would seem that the “else” function of the following is working but not the “if” function…
if (eventStart.getTime() <= today.getTime() && eventEnd.getTime() >= today) {
$w("#currentSessionText").show();
$w("#upcomingSessionText").hide();
}
else {
$w("#currentSessionText").hide();
$w("#upcomingSessionText").show();
}
I’m not sure if there’s now a problem with (eventStart.getTime() <= today.getTime() && eventEnd.getTime() >= today) l seeing as none of the other functions that rely on this bit of code seem to be working (e.g. the enterButton not enabling).
The page url is https://lm1223.editorx.io/responsive/sessiongate
and here is the whole page code…
import wixData from 'wix-data';
$w.onReady(function () {
//TODO: write your page related code here...
$w("#eventsDataset").onReady((async) => {
const today = new Date();
let itemObj = $w("#eventsDataset").getCurrentItem();
let eventStart = itemObj.start;
let eventEnd = itemObj.end;
if (eventStart.getTime() <= today.getTime() && eventEnd.getTime() >= today) {
$w("#enterButton").enable();
} else {
$w("#enterButton").disable();
}
let isEnabled = $w("#enterButton").enabled; // true
if (isEnabled) {
$w("#enterStageText").hide();
} else {
$w("#enterStageText").show();
}
if (eventStart.getTime() <= today.getTime() && eventEnd.getTime() >= today) {
$w("#currentSessionText").show();
$w("#upcomingSessionText").hide();
} else {
$w("#currentSessionText").hide();
$w("#upcomingSessionText").show();
}
});
$w("#eventsDataset").setFilter(wixData.filter()
.contains("status", "SCHEDULED")
.or(
wixData.filter()
.contains("status", "STARTED")
)
)
.then(() => {
console.log("Dataset is now filtered");
})
.catch((err) => {
console.log(err);
});
});
export function conductCheckbox_click(event) {
let isChecked = $w("#conductCheckbox").checked; // true
if (isChecked) {
$w("#disabledEnterButton").hide();
} else {
$w("#disabledEnterButton").show();
}
}
You need to check the data time today.getTime(), not just today, also, remove the equal from the end date, the end date should be greater than the current day, not greater or equal than current day.
if (Start.getTime() >= today.getTime() && End.getTime() > today.getTime()) {
You might want to check Wix Marketplace to find a developer to debug your code, or you can contact me through the links on my profile.
Okay thank you. I can’t afford to hire someone unfortunately so I will just have to try and figure it out.
Thank you for your help though.