Event ID Changes When Referenced

I’m using the Scheduler’s onEventAdded function and I need the ‘id’ of the event. However, the ID being returned to me is NOT what I’m expecting. Take this code:

scheduler.attachEvent("onEventAdded", function(id,ev){
    console.log(ev);
    alert(ev.id);
    alert(id);
});

So, in my browser console I can see the event id (id = “129148”) which is exactly what I need.

However, the alert pops up and shows that ev.id is: 1458133776567

The next alert shows the same thing: id= 1458133776567

What’s going on here? Everywhere I reference the ID of the added event I get this weird number. But, in the console dump it shows the actual value I need? How do I get that console value?

Thanks!

Hello,
when you create a new event, it’s sent to the backend where it will be inserted into the database and database will assign a permanent id to it. After that backend handler sends a database id back to the client so a new event could be updated.

So, when you do alert from onEventAdded, event has not obtained a database id yet and you see it’s temporary client-side id.
By the time you open expand event object in Firebug it obtains a database id, which you can see in a console.

If you need to use an id of a new event, you can detect when it receives it from the backend. If you use dhtmlx dataProcessor, it can be done via onAfterUpdate event :

dp.attachEvent("onAfterUpdate", function(id, action, tid, response){ if(action == "inserted"){ alert(tid);// event id } })
docs.dhtmlx.com/api__dataprocess … event.html

Thanks, I will try this. The API docs should be updated with this info, IMHO.