beforeUpdate event not triggered


Here is a part of my connector code:

require ("/var/www/project89/dhtmlx/connector/scheduler_connector.php");

function setAdvisor($action){
        $new_value = rand(0,100);
        error_log("New value = ".$new_value, 3, "/var/www/project89/log/debug.log");
$conn = new SchedulerConnector($db);

$conn->render_sql("SELECT * FROM events", "event_id","event_startdate,event_enddate,event_text,event_advisor_id");


I can insert/update/delete data from my scheduler but:

  • There is nothing in my log file
  • My field event_advisor_id is not updated

I guess that my function “setAdvisor” is not called.

Any idea why?



You need to place any events, options, configurations before render command. ( render_sql or render_table call will start data processing, so all commands after that point will be ignored )

$conn = new SchedulerConnector($db);
$conn->render_sql("SELECT * FROM events", "event_id","event_startdate,event_enddate,event_text,event_advisor_id");

Hi Stanislav,
Thank you for this hint. Now it works quite better since my function is called.

But there is still an error: when I update my event, the value “event_advisor_id” is not set updated and the event turns to red (showing there was an error during update).

This information will maybe help you to find an answer.
If I use the same function for the beforeInsert event it works perfectly.
The error appears only on the beforeUpdate event.

This code is working as I want:

function setAdvisor($action){
$conn = new SchedulerConnector($dokeos_database_connection);


$conn->render_sql("SELECT * FROM events where event_advisor_id = ".api_get_user_id(), "event_id","event_startdate,event_enddate,event_text,event_advisor_id");

If I comment the line with the attach of a beforeInsert event, it doesn’t work anymore.
I think it is because if I do not set the user_id, the created event is not part of the dataset of the render_sql. Could you confirm?

The issue can arise if

  • you have event_advisor_id in render_sql, but there is no such field in DB
  • you have event_advisor_id in render_sql, but client side doesn’t provide such field ( in case of scheduler it means that you don’t have a related section in lightbox, or adding new events through API without defining this field )

When you have beforeInsert handler it correctly sets value for the field, so it will be used correctly in the data saving operation.