I’m having trouble with
I am trying to create a Recurrence Event via Wix Events v2 API, It worked when I create single event with the Tickets initial type, but when I try to create Recurrence event it says to throws error saying validation error for field initialType even though I get initialType, I tried both Ticketing and RSVP event but both failed to create event. Also in the documentation it shows to set initialType as Tickets but the error throws to set it as Ticketing, so I tried both and both failed again.
Working in
Wix Studio Editor
Site link
What I’m trying to do
I am trying to create a event by my customer, but when I call the createEven, it throws
{
“event”: {
“title”: “ASDFGHJK”,
“location”: {
“type”: “VENUE”,
“address”: {
“country”: “US”,
“city”: “Almont”,
“streetAddress”: {
“name”: “948 Co Rd 744”,
“number”: “948”
},
“postalCode”: “81210-9702”,
“subdivision”: “CO”
}
},
“description”: “43”,
“languageCode”: “en”,
“registration”: {
“initialType”: “RSVP”,
“tickets”: {
“items”: [
{
“name”: “General Admission”,
“price”: {
“amount”: “0”,
“currency”: “GBP”
},
“taxSettings”: {
“type”: “INCLUDED_IN_PRICE”
},
“limitPerOrder”: 30
}
]
}
},
“dateAndTimeSettings”: {
“dateAndTimeTbd”: false,
“startDate”: “2026-01-10T10:00:00.000Z”,
“endDate”: “2026-01-10T11:00:00.000Z”,
“timeZoneId”: “Asia/Kolkata”,
“showTimeZone”: true,
“recurringEvents”: {
“individualEventDates”: [
{
“startDate”: “2026-01-10T10:00:00.000Z”,
“endDate”: “2026-01-10T11:00:00.000Z”,
“timeZoneId”: “Asia/Kolkata”,
“showTimeZone”: true
},
{
“startDate”: “2026-01-17T10:00:00.000Z”,
“endDate”: “2026-01-17T11:00:00.000Z”,
“timeZoneId”: “Asia/Kolkata”,
“showTimeZone”: true
},
{
“startDate”: “2026-01-24T10:00:00.000Z”,
“endDate”: “2026-01-24T11:00:00.000Z”,
“timeZoneId”: “Asia/Kolkata”,
“showTimeZone”: true
},
{
“startDate”: “2026-01-31T10:00:00.000Z”,
“endDate”: “2026-01-31T11:00:00.000Z”,
“timeZoneId”: “Asia/Kolkata”,
“showTimeZone”: true
}
]
}
}
},
“draft”: true
}
What I’ve tried so far
Let us know what you’ve already tested, changed, or searched
Extra context
import { eventCategories, createEvent, updateEventCategory } from "backend/events.web.js";
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
import { authentication, currentMember } from "wix-members-frontend";
function isSupportedFile(fileName, mimeType, fileSize) {
const supportedExtensions = ['jpg', 'jpeg', 'png'];
const maxSize = 15 * 1024 * 1024;
const extension = fileName.split('.').pop().toLowerCase();
return supportedExtensions.includes(extension) && fileSize <= maxSize;
}
$w.onReady(async function () {
const isLoggedIn = authentication.loggedIn();
if (!isLoggedIn) {
wixLocation.to('/customer-portal');
return;
}
$w('#toastText').hide();
$w('#toastBox').hide();
$w('#logout').onClick(async () => {
$w('#toastText').hide();
$w('#toastBox').hide();
await wixUsers.logout()
wixLocation.to('/customer-portal')
});
const requestCategory = await eventCategories();
const categoryItems = requestCategory._items;
const requiredCategory = [
"Art",
"Family Friendly",
"Farmer’s Markets",
"Festivals & Special Events",
"Fitness",
"Happy Hours",
"Holidays",
"Live Music",
"Nearby Events",
"Theatre"
]
const requiredLower = requiredCategory.map(cat => cat.toLowerCase());
categoryItems.forEach(data => {
const isAvailable = requiredLower.includes(data.name.toLowerCase())
console.log('Category: ', data, ' ', isAvailable)
});
const filteredItems = categoryItems.filter(item =>
requiredLower.includes(item.name.toLowerCase())
);
const dropdownOptions = filteredItems.map(item => ({
label: item.name,
value: item._id
}));
$w('#category1').options = dropdownOptions;
$w('#category2').options = dropdownOptions;
$w('#category3').options = dropdownOptions;
if (dropdownOptions.length > 0) {
// $w('#category1').value = dropdownOptions[0].value;
$w('#category1').value = "Select a Event Category 1";
$w('#category2').value = "Select a Event Category 2";
$w('#category3').value = "Select a Event Category 3";
// $w('#category2').value = dropdownOptions[0].value;
// $w('#category3').value = dropdownOptions[0].value;
}
const allCategoryOptions = [...dropdownOptions];
function getRecurringSettings() {
const radioValue = $w('#radioGroup3').value;
// Only process if it's a recurring event
if (radioValue !== 'Radio Button2') {
return null; // Single event — no recurrence
}
const datesValue = $w('#datesdropdown').value;
if (datesValue === 'specificDates') {
// Note: For specific dates, you'll need to collect them via a button/repeater
// For now, returning placeholder — implement separately if needed
return {
type: "SPECIFIC_DATES",
dates: [] // You must populate this when user clicks #datesButton
};
}
if (datesValue !== 'repeatingDates') {
return null;
}
// === REPEATING / RECURRING EVENT ===
const frequencyValue = $w('#frequencydropdown').value;
const repeatEveryValue = $w('#repeatsevery').value || 'daysrepeats';
const endsValue = $w('#endsdropdown').value || 'never';
const startDate = $w('#startDatePicker').value;
const endDate = $w('#endDatePicker').value; // This is the daily end date (not recurrence end)
const startTime = $w('#startTimePicker').value;
const endTime = $w('#endTimePicker').value;
if (!startDate || !endDate || !startTime || !endTime) {
throw new Error("Start/end date & time are required for recurring events");
}
// const startDateTime = new Date(startDate);
// const endDateTime = new Date(endDate); // same day end time
const startTP = parseTimeToObject(startTime);
const endTP = parseTimeToObject(endTime);
if (!startTP || !endTP) {
throw new Error("Invalid time selected");
}
startDateTime.setHours(startTP.hours, startTP.minutes, 0, 0);
endDateTime.setHours(endTP.hours, endTP.minutes, 0, 0);
let recurrenceRule = {
type: "RECURRING",
startDateTime: startDateTime.toISOString(),
endDateTime: endDateTime.toISOString(),
timeZoneId: $w('#timezoneDropdown').value || 'America/Chicago',
recurrence: {}
};
// === Build RRULE-like structure (Wix Events API compatible) ===
let rrule = {
frequency: '',
interval: 1,
byDay: [],
byMonthDay: null,
until: null,
count: null
};
// Frequency mapping
if (frequencyValue === 'dailyfrequency') {
rrule.frequency = 'DAILY';
} else if (frequencyValue === 'weeklyfrequency') {
rrule.frequency = 'WEEKLY';
rrule.byDay = $w('#checkboxGroup1').value || []; // e.g., ["MO", "WE", "FR"]
} else if (frequencyValue === 'monthlyfrequency') {
rrule.frequency = 'MONTHLY';
const dayOption = $w('#repeatson').value;
if (dayOption === 'last') {
rrule.byDay = [{ weekday: startDateTime.getDay(), nth: -1 }]; // Last X of month
} else {
rrule.byMonthDay = parseInt(dayOption);
}
} else if (frequencyValue === 'customfrequency') {
const interval = Number($w('#Num1').value) || 1;
rrule.interval = interval > 0 ? interval : 1;
if (repeatEveryValue === 'daysrepeats') {
rrule.frequency = 'DAILY';
} else if (repeatEveryValue === 'weeksrepeats') {
rrule.frequency = 'WEEKLY';
rrule.byDay = $w('#checkboxGroup1').value || [];
} else if (repeatEveryValue === 'monthsrepeats') {
rrule.frequency = 'MONTHLY';
const dayOption = $w('#repeatson').value;
if (dayOption === 'last') {
rrule.byDay = [{ weekday: startDateTime.getDay(), nth: -1 }];
} else {
rrule.byMonthDay = parseInt(dayOption);
}
}
}
// === Ends Logic ===
if (endsValue === 'specificdate') {
const untilDate = $w('#Endingdate').value;
if (untilDate) {
const until = new Date(untilDate);
until.setHours(23, 59, 59, 999);
rrule.until = until.toISOString();
}
} else if (endsValue === 'noofevents') {
const count = Number($w('#Num2').value);
if (count > 0) {
rrule.count = count;
}
}
// "Never" → no until/count
recurrenceRule.recurrence = rrule;
return recurrenceRule;
}
function updateAllVisibility() {
const radioValue = $w('#radioGroup3').value; // Radio Button1 or Radio Button2
const datesValue = $w('#datesdropdown').value || ''; // specificDates or repeatingDates
const frequencyValue = $w('#frequencydropdown').value || ''; // daily, weekly, monthly, custom
const repeatEveryValue = $w('#repeatsevery').value || ''; // days, weeks, months
const endsValue = $w('#endsdropdown').value || ''; // specificdate or noofevents
// 1. Hide ALL possible recurring fields first (clean slate)
const allRecurringElements = [
'#datesdropdown', '#datesButton',
'#Endingdate', '#checkboxGroup1', '#endsdropdown', '#Num1', '#Num2',
'#frequencydropdown', '#repeatsevery', '#repeatson'
];
allRecurringElements.forEach(id => $w(id).hide());
// Also hide single event pickers when in recurring mode
$w('#startDatePicker').hide();
$w('#endDatePicker').hide();
$w('#startTimePicker').hide();
$w('#endTimePicker').hide();
// ========================================================================
// CASE 1: Single Event (Radio Button1)
// ========================================================================
if (radioValue === 'Radio Button1') {
$w('#startDatePicker').show();
$w('#endDatePicker').show();
$w('#startTimePicker').show();
$w('#endTimePicker').show();
$w('#text59').hide();
$w('#text60').hide();
$w('#text61').hide();
return; // Nothing else to show
}
// ========================================================================
// CASE 2: Recurring Event (Radio Button2)
// ========================================================================
if (radioValue === 'Radio Button2') {
$w('#datesdropdown').show(); // Always visible in recurring mode
$w('#text59').show();
$w('#text56').hide();
$w('#text60').show();
$w('#text61').show();
// ------------------ specificDates ------------------
if (datesValue === 'specificDates') {
$w('#text59').hide();
$w('#text60').hide();
$w('#text61').hide();
$w('#text56').show();
$w('#startDatePicker').show();
$w('#endDatePicker').show();
$w('#startTimePicker').show();
$w('#endTimePicker').show();
$w('#datesButton').show();
return;
}
// ------------------ repeatingDates ------------------
if (datesValue === 'repeatingDates') {
$w('#text59').show();
$w('#text56').hide();
$w('#text60').show();
$w('#text61').show();
$w('#startDatePicker').show();
$w('#endDatePicker').show();
$w('#startTimePicker').show();
$w('#endTimePicker').show();
$w('#datesButton').hide();
$w('#Endingdate').show();
$w('#checkboxGroup1').show();
$w('#endsdropdown').show();
$w('#frequencydropdown').show();
$w('#repeatsevery').hide();
// === Frequency Logic ===
if (frequencyValue === 'dailyfrequency') {
$w('#checkboxGroup1').hide();
$w('#repeatson').hide();
} else if (frequencyValue === 'weeklyfrequency') {
$w('#checkboxGroup1').show();
$w('#repeatson').hide();
} else if (frequencyValue === 'monthlyfrequency') {
$w('#checkboxGroup1').hide();
$w('#repeatson').show();
} else if (frequencyValue === 'customfrequency') {
$w('#checkboxGroup1').hide();
$w('#repeatson').hide();
$w('#repeatsevery').show();
$w('#Num1').show();
// Inside repeatsevery (days/weeks/months)
if (repeatEveryValue === 'daysrepeats') {
$w('#Num1').show();
$w('#checkboxGroup1').hide();
} else if (repeatEveryValue === 'weeksrepeats') {
$w('#Num1').show();
$w('#checkboxGroup1').show();
} else if (repeatEveryValue === 'monthsrepeats') {
$w('#Num1').show();
$w('#repeatson').show();
$w('#checkboxGroup1').hide();
}
}
// === Ends Dropdown Logic ===
if (endsValue === 'specificdate') {
$w('#Endingdate').show();
$w('#Num2').hide();
} else if (endsValue === 'noofevents') {
$w('#Num2').show();
$w('#Endingdate').hide();
}
}
}
}
$w('#radioGroup3').value = 'Radio Button1';
$w('#datesdropdown').value = 'specificDates';
updateAllVisibility();
// Listeners — call the same function on every change
$w('#radioGroup3').onChange(updateAllVisibility);
$w('#datesdropdown').onChange(updateAllVisibility);
$w('#frequencydropdown').onChange(updateAllVisibility);
$w('#repeatsevery').onChange(updateAllVisibility);
$w('#endsdropdown').onChange(updateAllVisibility);
// ==========================================================================
// Function to refresh dropdowns so selected categories are removed from others
function refreshCategoryDropdowns(changedDropdown) {
// Collect all selected categories (ignore placeholder values)
const selectedValues = [
$w('#category1').value,
$w('#category2').value,
$w('#category3').value
].filter(val => !val.startsWith("Select a Event Category"));
// For each dropdown (1, 2, 3)
[$w('#category1'), $w('#category2'), $w('#category3')].forEach((dropdown, index) => {
const placeholder = `Select a Event Category ${index + 1}`;
const currentValue = dropdown.value;
// Filter available options so other dropdowns can’t pick already-selected ones
const availableOptions = allCategoryOptions.filter(opt =>
!selectedValues.includes(opt.value) || opt.value === currentValue
);
// Rebuild dropdown options
dropdown.options = [
{ label: placeholder, value: placeholder },
...availableOptions
];
// Keep the user’s selection visible even after refresh
if (availableOptions.some(opt => opt.value === currentValue)) {
dropdown.value = currentValue;
} else {
dropdown.value = placeholder;
}
});
}
// Attach listeners to update others when any category changes
['#category1', '#category2', '#category3'].forEach(id => {
$w(id).onChange(() => refreshCategoryDropdowns($w(id)));
});
// Initialize dropdowns once on page load
refreshCategoryDropdowns();
const countryMap = {
"India": "IN",
"United States": "US",
"United Kingdom": "GB",
"Australia": "AU",
"IN": "IN",
"US": "US",
"GB": "GB",
"AU": "AU"
};
let uploadedImageUrl = null;
$w('#toastText').hide();
$w('#toastBox').hide();
// Function to toggle field visibility based on radio button selection
function toggleFields(selectedValue) {
console.log('Selected radio button value:', selectedValue);
// Hide all fields initially
$w('#physicalLocationInput').hide();
$w('#onlineLocationInput').hide();
$w('#locationTBD').hide();
// Show relevant fields based on selected value
if (selectedValue === 'Radio button1') {
$w('#physicalLocationInput').show();
console.log('Showing physicalLocationInput');
} else if (selectedValue === 'Radio button2') {
$w('#onlineLocationInput').show();
console.log('Showing onlineLocationInput');
} else if (selectedValue === 'Radio button3') {
$w('#locationTBD').show();
console.log('Showing input6');
} else {
console.warn('Unknown radio button value:', selectedValue);
}
}
// Set default radio button and trigger field visibility
$w('#radioGroup2').value = 'Radio button1'; // Default to Radio button1
toggleFields('Radio button1'); // Initialize field visibility
// Handle radio button change
$w('#radioGroup2').onChange(() => {
const selectedValue = $w('#radioGroup2').value;
toggleFields(selectedValue);
});
$w('#imageUpload').onChange(async () => {
if ($w('#imageUpload').value.length === 0) return;
const file = $w('#imageUpload').value[0];
const fileName = file.name;
const fileSize = file.size;
console.log('Is Supported::', isSupportedFile(fileName, fileSize));
if (!isSupportedFile(fileName, fileSize)) {
showToast('Only JPG and PNG images are allowed.', 'error');
await $w('#imageUpload').reset();
uploadedImageUrl = null;
return;
}
try {
const uploadResponse = await $w('#imageUpload').startUpload();
uploadedImageUrl = uploadResponse.url;
console.log('Uploaded image URL:', uploadedImageUrl);
} catch (error) {
console.error('Image upload error:', error);
showToast('Failed to upload image', 'error');
}
});
function getMimeType(fileName) {
const extension = fileName.split('.').pop().toLowerCase();
const mimeTypes = {
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
png: 'image/png',
gif: 'image/gif',
bmp: 'image/bmp',
};
return mimeTypes[extension] || 'image/jpeg';
}
function isSupportedFile(fileName, fileSize) {
const supportedExtensions = ['jpg', 'jpeg', 'png'];
const maxSize = 25 * 1024 * 1024;
const extension = fileName.split('.').pop().toLowerCase();
return supportedExtensions.includes(extension) && fileSize <= maxSize;
}
// Helper function to safely get and trim string values
function safeTrim(value, defaultValue = '') {
return typeof value === 'string' ? value.trim() : defaultValue;
}
// Helper function to reset the form
function resetForm() {
// Reset text inputs
$w('#eventNameInput').value = '';
$w('#onlineLocationInput').value = '';
$w('#input6').value = '';
$w('#conferenceLinkInput').value = '';
$w('#link').value = '';
$w('#shortTeaserInput').value = '';
// Reset dropdowns to defaults
$w('#dropdownCurrency').value = 'GBP';
$w('#inputTicketLimit').value = '30';
// $w('#category1').value = $w('#category1').options[0]?.value || '';
$w('#category1').value = "Select a Event Category 1";
$w('#category2').value = "Select a Event Category 2";
$w('#category3').value = "Select a Event Category 3";
// $w('#category2').value = $w('#category2').options[0]?.value || '';
// $w('#category3').value = $w('#category3').options[0]?.value || '';
$w('#timezoneDropdown').value = 'America/Chicago';
// Reset date/time pickers
$w('#startDatePicker').value = null;
$w('#endDatePicker').value = null;
$w('#startTimePicker').value = null;
$w('#endTimePicker').value = null;
$w('#radioGroup3').value = 'Radio Button1';
$w('#datesdropdown').value = 'specificDates';
$w('#frequencydropdown').value = 'daily';
$w('#repeatsevery').value = 'days';
$w('#endsdropdown').value = 'specificdate';
updateAllVisibility();
// Reset image upload
// $w('#imageUpload').value = [];
uploadedImageUrl = null;
console.log('Image upload field reset:', $w('#imageUpload').value);
$w('#imageUpload').reset();
// Reset physical location input
$w('#physicalLocationInput').value = null; // Explicitly reset address input
console.log('Physical location input reset:', $w('#physicalLocationInput').value);
// Maintain visibility based on current radio button selection
toggleFields($w('#radioGroup2').value);
}
// === Toast Notification System ===
function showToast(message, type = 'success') {
const isError = type === 'error';
const color = isError ? '#FF3B30' : '#28A745';
const icon = isError ? '❌' : '✅';
const backgroundColor = isError ? '#ffe6e6' : '#e6ffed';
if ($w('#toastBox').timeoutId) clearTimeout($w('#toastBox').timeoutId);
// Update text
$w('#toastText').text = `${icon} ${message}`;
$w('#toastText').style.color = color;
$w('#toastText').style.fontSize = '16px';
$w('#toastText').style.fontWeight = '600';
$w('#toastText').show();
// Style box
$w('#toastBox').style.backgroundColor = backgroundColor;
$w('#toastBox').style.border = `1px solid ${color}`;
$w('#toastBox').style.borderRadius = '12px';
$w('#toastBox').style.boxShadow = '0px 4px 12px rgba(0,0,0,0.2)';
$w('#toastBox').style.padding = '10px 18px';
// Scroll to toast
$w('#toastBox').scrollTo();
// Show and hide logic
$w('#toastBox').show('slide', { direction: 'bottom', duration: 300 });
$w('#toastBox').timeoutId = setTimeout(() => {
$w('#toastBox').hide('slide', { direction: 'bottom', duration: 300 });
}, 4000);
}
$w('#createEventBtn').onClick(async () => {
// Validate required fields before showing loader
const eventName = safeTrim($w('#eventNameInput').value);
const selectedLocationRaw = $w('#radioGroup2').value;
const addressInput = $w('#physicalLocationInput').value;
const onlineLink = safeTrim($w('#onlineLocationInput').value);
const otherLocation = safeTrim($w('#locationTBD').value);
const startDate = $w('#startDatePicker').value;
const endDate = $w('#endDatePicker').value;
const startTime = $w('#startTimePicker').value;
const endTime = $w('#endTimePicker').value;
const result2 = addressInput.formatted.split(",");
const streetname = result2[0];
// console.log("===== Result2", streetname);
console.log('Raw inputs:', {
eventName,
physicalLocation: addressInput,
onlineLocation: onlineLink,
otherLocation,
selectedLocationType: selectedLocationRaw,
imageUpload: $w('#imageUpload').value,
uploadedImageUrl
});
// Validate event name
if (!eventName) {
showToast('Event name is required', 'error');
return;
}
const valueMap = {
'Radio button1': 'Physical location',
'Radio button2': 'Online',
'Radio button3': 'To be decided (TBD)'
};
const selectedLocationType = valueMap[selectedLocationRaw];
//Location object
let locationData = {};
if (selectedLocationType === 'Physical location') {
if (!addressInput || !addressInput.formatted || addressInput.formatted.trim() === '') {
showToast('Physical Location is required', 'error');
return;
}
const { city, country, streetAddress, postalCode, subdivision } = addressInput;
const countryCode = countryMap[country] || countryMap[country?.toUpperCase()] || 'IN';
// Street Name
const result2 = addressInput.formatted.split(",");
const streetname = result2[0];
console.log("===== Result2", streetname);
const streetName = streetname;
const streetNumber = safeTrim(streetAddress?.number) || '';
const validPostalCode = safeTrim(postalCode) && postalCode !== 'undefined' ? postalCode : '000000';
locationData = {
type: 'VENUE',
address: {
country: countryCode,
city: safeTrim(city),
streetAddress: {
name: streetName,
number: streetNumber
},
postalCode: validPostalCode,
subdivision: safeTrim(subdivision) || ''
}
};
} else if (selectedLocationType === 'Online') {
if (onlineLink || onlineLink.trim() !== '') {
showToast('Physical location type is required', 'error');
return;
}
locationData = {
type: 'ONLINE',
conferenceLink: safeTrim($w('#conferenceLinkInput').value)
};
} else if (selectedLocationType === 'To be decided (TBD)') {
if (otherLocation || otherLocation.trim() !== '') {
showToast('Physical location type is required', 'error');
return;
}
locationData = {
type: 'UNKNOWN_LOCATION',
locationTbd: true,
name: otherLocation || 'To be decided'
};
} else {
showToast('Invalid location type selected', 'error');
return;
}
// Validate date and time fields
if (!startDate || !endDate && !startTime || !endTime) {
showToast('Date and time fields are required', 'error');
return;
}
// Check if end date is before start date
if (endDate < startDate) {
showToast('End date cannot be before start date', 'error');
return;
}
if (!startDate || !endDate) {
showToast('Date fields are required', 'error');
return;
}
if (!startTime || !endTime) {
showToast('Time fields are required', 'error');
return;
}
// If all validations pass, show the loader
const createBtn = $w('#createEventBtn');
const originalText = createBtn.label;
createBtn.label = '⏳ Creating event...';
createBtn.disable();
try {
const startTimeParsed = parseTimeValue(startTime);
const endTimeParsed = parseTimeValue(endTime);
function parseTimeValue(timeVal) {
if (!timeVal) return null;
if (timeVal instanceof Date) {
return { hours: timeVal.getHours(), minutes: timeVal.getMinutes() };
}
if (typeof timeVal === 'string') {
const match = timeVal.match(/(\d{1,2}):(\d{2})\s*(AM|PM)?/i);
if (!match) return null;
let hours = parseInt(match[1], 10);
const minutes = parseInt(match[2], 10);
const ampm = match[3]?.toUpperCase();
if (ampm === 'PM' && hours < 12) hours += 12;
if (ampm === 'AM' && hours === 12) hours = 0;
return { hours, minutes };
}
return null;
}
const startDateTime = new Date(startDate);
startDateTime.setHours(startTimeParsed.hours, startTimeParsed.minutes, 0, 0);
const endDateTime = new Date(endDate);
endDateTime.setHours(endTimeParsed.hours, endTimeParsed.minutes, 0, 0);
const descriptionText = safeTrim($w('#conferenceLinkInput').value) ?
`${safeTrim($w('#conferenceLinkInput').value).replace(/<[^>]+>/g, '')}` :
'';
const eventPageUrl = $w('#link').value;
if (eventPageUrl) {
const htmlLink = `<a href="${eventPageUrl}" target="_blank">${eventPageUrl}</a>`;
$w('#conferenceLinkInput').value = htmlLink;
console.log("eventlink2", htmlLink);
}
console.log("eventlink", eventPageUrl);
// const f=$w('#conferenceLinkInput').value;
// const f2=safeTrim($w('#conferenceLinkInput').content);
// const f3=`${safeTrim($w('#conferenceLinkInput').value).replace(/<[^>]+>/g, '')}`;
// console.log("--Big box value",f);
// console.log("--Big box2 value",f2);
// console.log("--Big box3 value",f3);
const category = [$w('#category1').value, $w('#category2').value, $w('#category3').value]
const uniqueCategories = new Set(category.filter(Boolean)); // removes empty values too
if (uniqueCategories.size < category.length) {
showToast('Each category must be unique.', 'error');
return;
}
if ($w('#radioGroup3').value === 'Radio Button2') {
try {
getRecurringSettings(); // Will throw if dates/times missing
} catch (err) {
showToast(err.message, 'error');
return;
}
}
const recurrenceData = getRecurringSettings();
const dateAndTimeSettings = {
timeZoneId: $w('#timezoneDropdown').value || 'America/Chicago'
};
if (recurrenceData && recurrenceData.type === "RECURRING") {
dateAndTimeSettings.recurrence = recurrenceData.recurrence;
dateAndTimeSettings.startDateTime = recurrenceData.startDateTime;
dateAndTimeSettings.endDateTime = recurrenceData.endDateTime;
} else {
// Single or specific dates
dateAndTimeSettings.startDate = startDateTime.toISOString();
dateAndTimeSettings.endDate = endDateTime.toISOString();
}
const eventData = {
event: {
title: eventName,
location: locationData,
// dateAndTimeSettings: dateAndTimeSettings,
description: descriptionText,
languageCode: 'en',
registration: {
initialType: 'TICKETING',
tickets: {
items: [{
name: 'General Admission',
price: {
amount: '0',
currency: safeTrim($w('#dropdownCurrency').value, 'GBP')
},
taxSettings: { type: 'INCLUDED_IN_PRICE' },
limitPerOrder: Number(safeTrim($w('#inputTicketLimit').value, '30')) || 30
}]
}
},
dateAndTimeSettings: {
dateAndTimeTbd: false,
// First occurrence preview (required for Wix summary)
startDate: "2026-01-10T10:00:00.000Z",
endDate: "2026-01-10T11:00:00.000Z",
timeZoneId: "Asia/Kolkata",
showTimeZone: true,
recurringEvents: {
individualEventDates: [{
startDate: "2026-01-10T10:00:00.000Z",
endDate: "2026-01-10T11:00:00.000Z",
timeZoneId: "Asia/Kolkata",
showTimeZone: true
},
{
startDate: "2026-01-17T10:00:00.000Z",
endDate: "2026-01-17T11:00:00.000Z",
timeZoneId: "Asia/Kolkata",
showTimeZone: true
},
{
startDate: "2026-01-24T10:00:00.000Z",
endDate: "2026-01-24T11:00:00.000Z",
timeZoneId: "Asia/Kolkata",
showTimeZone: true
},
{
startDate: "2026-01-31T10:00:00.000Z",
endDate: "2026-01-31T11:00:00.000Z",
timeZoneId: "Asia/Kolkata",
showTimeZone: true
}
]
}
},
mainImage: uploadedImageUrl || undefined
},
draft: true,
};
console.log('Sending eventData to backend:', JSON.stringify(eventData, null, 2));
const result = await createEvent(eventData);
console.log('Event Created Result: ', result);
console.log('EventID:::', [result.data._id]);
console.log('Category Selected', category);
if (result.success) {
showToast('Event created successfully!', 'success');
for (const cate of category) {
try {
const categoryUpdated = await updateEventCategory(cate, [result.data._id]);
console.log('Category Updated Successfully:', categoryUpdated);
} catch (err) {
console.error(`Failed to update category ${cate}:`, err);
}
}
resetForm();
} else {
console.log('Result:::', result);
showToast(result.error || 'Failed to create event', 'error');
}
} catch (error) {
console.log('Result:::', error);
showToast(error.message || 'An unexpected error occurred', 'error');
} finally {
// Restore button state
createBtn.label = originalText;
createBtn.enable();
}
});
});
I tried creating with three different tyoe including RSVP, TICKETING and TICKETS. Nut still not working