Change one value of column in scheduler

Hello guys.
I need help with setting a value for ONE specific column once i create an event with the scheduler.

My query takes all the input from the lightbox form.
But i have a column called “svar”.

What I want to do is, once I create an event, i want to update the value of the column “svar” to 0.
The only way i know how to do this is to attatch a textarea in the lightbox and do map_to:svar, but then i have a field in the lightbox that i dont want.
I want to make the value “0” as soon as i create an event.

I want to make it 0 because i will later on have and accept/deny button in a backend app where accept will change the “svar” column to 1 and deny will change “svar” to 2.

0 = pending
1 = accepted
2 = denied

I have this.

scheduler.templates.event_bar_text = function(start,end,event){
			if(event.svar == "0"){
				event.text = "Pending";
			}
			else if(event.svar =="1"){
				event.text = "Accepted";
			}
			else {
				event.text = "Denied";
				}
			return event.text;
			};

Now, this code works perfectly. If i manually change the “svar” value of two events in the database. one event to 0 and one event to 1, they will show the correct text. pending and accepted. So this code works and it does take the value from the DB.

I want to make it so whenever I create an event, i want the svar column for the event to be set to 0.

Everytime i create an event i get the text “Incorrect field name used: svar” in the log.
I guess since svar is in the query but nothing mapped to it.

You can use onEventCreated handler in the scheduler

docs.dhtmlx.com/scheduler/api__s … event.html

This handler is called after event creating initiated, but before any data is sent to a server-side. So its a perfect place to modify event object and set any default values.

Hey thank you for the tip, but I still cant figure out how to do this. Do I initiate a query? How would I change the value of a column?

its still giving me the error “Incorrect field name used: svar”

the code im using is

                scheduler.attachEvent("onEventCreated", function(id,e){
		          event.svar = 1;
		});

I am pretty sure this is wrong. Im very very new to javascript. Just knowing how to call queries or whatever i need to send data to the database would get me far. Just knowing the logic of it and I will know how to continue.

How would I increase the value of svar? all other columns get their value from lightbox input.
I do not want to change ALL events value at once. I only want to change the value of the event i am creating.

nvm got it to work!!!

	scheduler.attachEvent("onEventCreated", function(id,e){
	var ev = this.getEvent(id);
	ev.svar = 1;
	});

Thank you so much mate