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->event->attach("beforeUpdate","setAdvisor");
$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.
function setAdvisor($action){
$action->set_value("event_advisor_id",api_get_user_id());
}
$conn = new SchedulerConnector($dokeos_database_connection);
$conn->event->attach("beforeInsert","setAdvisor");
$conn->event->attach("beforeUpdate","setAdvisor");
$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?
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.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan