getRecDates: How to Iterate Through Values

I’m having trouble iterating through the values returned from getRecDates. It is merely listing it as an Object. I believe that it is an array but cannot seem to look through it like a normal array. Here is some code:

scheduler.attachEvent(“onEventSave”, function (a, b) {
var dates = scheduler.getRecDates(b.id,1000);
for (var i = 0; i < dates.length; i++) {
alert(“dates[” + i + “] is =>’” + dates[i] + “’”);
}
var c = this.getEvent(a);
if (!c.rec_type && b.rec_type && (a + “”).indexOf("#") == -1) this._select_id = null; return !0
});

Any thoughts?

Hello,

getRecDates returns array of objects, each object has start_date and end_date properties:

[ { start_date: date, end_date: date }, { start_date: next_date, end_date: next_date }, ... ]
Please note that in onEventSave event you won’t receive full list of event occurrences.

Kind regards,
Ilya

I’ll try that. Thanks but is there an event where I can get all of scheduling dates if onEventSave is not the best place?

If you want to do it after save operation ends you can try to use onAfterLightbox event, it is called when lightbox is closed and edit operation is fully finished ( onEventSave called when saving operation starts )

I will try that. The point is that we have to decipher all dates scheduled (insert/update/delete) into a format that does not use rec_dates (i.e., one record per scheduled event).

Ok. onAfterLightbox is not passed the event like onEventSave does so how do I get the event.id to pass to getRecDates?

Yep, sorry for incorrect suggestion.
Try to use
onEventAdded
onEventChanged
handlers, they are occurs after edit operation finished, and both provide the event id.

I’m not sure what is wrong then. Here is what I have:
scheduler.attachEvent(“onEventAdded”, function (a) {
var dates = scheduler.getRecDates(a, 1000);
alert(dates.length); // RETURNS 0
}

This should work, right? When I alert(a); it displays a very long number if that helps.

Event in question is really recurring?
getRecDates will return empty set for the normal events, and array of objects only for recurring events.

When I alert(a); it displays a very long number
It looks correct - long number is default id for the new event

Ok. This is what I see. Changed seems to work as expected because it has the actual id for getRecDates but Added only gets a temp ID (long number). Is there a way during Added to get the actual db ID for getRecDates?

Actual DB id will appear only after callback from server side. It is not available yet when onEventAdded is called

onEventSaving
onEventAdded

  • request to server side sent
    onAfterLightBox
    … some time…
  • response from server side received
  • id updated from temp to real one

You can use onAfterUpdate event of dataprocessor to catch moment when response from server side was received.

Hello,

Or you can use onEventIdChange event:

scheduler.attachEvent("onEventIdChange", function(old_event_id,new_event_id){ //any custom logic here });
Kind regards,
Ilya