Custom Form / Recurring events

For the scheduler I am using a custom lightbox form. I have everything working except for recurring event fields because I am not sure how to set them manually. Here is an example of what I have working

var event = scheduler.getEvent(scheduler.getState().lightbox_id);
var values = form2a.getFormData();
event.text = values.Subject;
event.start_date = values.StartDate;
event.end_date = values.EndDate;

This successfully adds an event with the subject/times on the form. I am trying to also set a recurring field like this but it fails

event.rec_type = “day_1___”;

How would I go about manually setting a daily recurring pattern on the event variable?

You need to

  • set rec_type and rec_pattern
event.rec_type = event.rec_pattern = "day_1___";
  • set event_length
ev.event_length = (ev.end_date - ev.start_date)/1000;
  • set end date to date of last recurring event ( set to distant future for events without end recurring date )
ev.end_date = new Date(2099,1,1);

I think this works for creating new events. Are there any known issues with changing the recurrence of an existing events? Using the example you gave above this is what his happening

  • New event, seems to work OK

  • Edit non-recurring event by changing to daily. Record disappears from calendar after saving. Backend is working correctly and it shows after refreshing the browser window

  • Edit weekly recurring event by changing to daily has a different problem but I will ignore for now.

If you are changing the above 3 properties for normal event to convert it to recurring - there must not be any problem with data saving. Same for conversion from one recurring type to different one.

If you are using default server side code for recurring events, it may have “insert_related” handler, which will respond with “delete” status, but it must do so only when you have rec_type as “none” (it is necessary to delete instance of recurring event). Try to comment this code. As far as I can see this is the only place which can cause wrong behavior similar to one in your case.

If issue still occurs - can you share some demo or link where it can be checked.

The backend is not hitting the delete part since I am changing the records subject and that is saving correctly. For existing records it seems to be a problem with the event_length. Any idea why this would happen?

event.event_length = 3600;
console.log(event); <-- the event_length field shows as 505141199.532
console.log(event.event_length); <-- shows as 3600

It looks very strange. I don’t have any idea, how it can occurs.
Please provide any kind of sample or demo link, where problem can be checked.