Scheduler DB Persistence with Data Processor and Connector

I’m trying to persist scheduler events in a database and I’m running into issues loading events back into the scheduler. I’m using both data processor and connector. The specific problem I’m having involves mixing repeating events with single events.

If the user creates a new event, leaving the repeating event “Disabled”, and hits the save button, the rec_type field in the database receives the value “null”. When connector loads the null value back into scheduler it breaks with a “Object doesn’t support this property or method” javascript error.

If the user creates a new event and configures the repeating event box (so repeating events are enabled) the rec_type field will receive a value and the schedule will correctly load the event.

I assume either my Data Processor is not correctly writing single event details into the database, or my Connector table is formatted wrong for mixed single and repeating events. What values are expected in the rec_type, event_length, and event_pid fields if the event is a single event?

The following is my Connector render SQL string.

schedulerConnector.render_sql(sql_query, "id", "event_start,event_end,event_text,rec_type,event_length,event_pid");

This is some example XML that the Connector returns. The second event will break the Scheduler.

<?xml version='1.0' encoding='utf-8' ?> <data> <event id='1329934392881' > <start_date><![CDATA[2012-03-01 00:00]]></start_date> <end_date><![CDATA[2012-04-01 00:00]]></end_date> <text><![CDATA[New event]]></text> <rec_type><![CDATA[month_1___#1]]></rec_type> <event_length><![CDATA[300]]></event_length> <event_pid><![CDATA[0]]></event_pid> </event> <event id='1329938151175' > <start_date><![CDATA[2012-03-15 00:00]]></start_date> <end_date><![CDATA[2012-03-15 00:05]]></end_date> <text><![CDATA[New event]]></text> <rec_type><![CDATA[null]]></rec_type> <event_length><![CDATA[0]]></event_length> <event_pid><![CDATA[0]]></event_pid> </event> </data>

Which database you are using ?
What is the table schema ( rec_type especially ) ?

Normally xml must have
<rec_type></rec_type>
not
<rec_type></rec_type>

rec_type field has varchar type, so it must return empty string for empty cells.

Also, please try to enable logging and check incoming parameters and produced sql query.
docs.dhtmlx.com/doku.php?id=dhtm … nd_logging

I’m using an Oracle database.

The query from my log looks as follows:

[code]====================================
Log started, Thu Feb 23 14:41:21 CST 2012

DB query
SELECT SCHEDULE_ID AS “id”, EVENT_START AS “event_start”, EVENT_END AS “event_end”, EVENT_TEXT AS “event_text”, EVENT_TYPE as “rec_type”, EVENT_LENGTH as “event_length”, EVENT_PID as “event_pid” FROM SCHEDULE WHERE SCENARIO_ID = 100

Done in : 0ms[/code]

The relevant portion of my table schema is:

"SCHEDULE_ID" VARCHAR2(64 BYTE) NOT NULL ENABLE, "SCENARIO_ID" NUMBER NOT NULL ENABLE, "EVENT_START" VARCHAR2(64 BYTE) NOT NULL ENABLE, "EVENT_END" VARCHAR2(64 BYTE) NOT NULL ENABLE, "EVENT_TEXT" VARCHAR2(256 BYTE), "EVENT_TYPE" VARCHAR2(64 BYTE), "EVENT_LENGTH" NUMBER, "EVENT_PID" NUMBER
Note: the EVENT_TYPE attribute is storing the rec_type value.

I had isolated the problem to the “null” string being passed back instead of the empty string “” in values of rect_type. I was able to fix it by extending the ConnectorBehavior for the Scheduler connector and adding a beforeRender function that checked for a null rect_type and replaced the null with “”. I don’t know if this is the optimal solution, but appears to be working.

Solution with beforeRender must not cause any side effects.
We will try to reconstruct issue locally and include some kind of fix in next update.

I sure wish there had been a resolution posted here. I am having the exact same problem with Scheduler putting in the null into the database for the rec_type.

Did this ever get resolved?

OK… I have fixed this on my scheduler anyway!

I inserted the following code in my connector php file:

$scheduler->sql->query(“UPDATE YOURTABLENAMEHERE SET rec_type = REPLACE(rec_type, ‘null’, ‘’);”);

I placed that code just above the final line which is the $scheduler->render_table line.

Hope it works for you as well. :slight_smile:

Hello,

graphicsmart, I still would suggest attaching onBeforeRender handler instead of modifying connector files (as they could be updated and fix will be lost).
onBeforeRender handler won’t cause any side effects.

Kind regards,
Ilya