BeforeRenderSet event ID

In the “BeforeRenderSet” event, I need to know the ID of the event that was double-clicked. I’ve tried the methods below, but they both return an error when I try to load the scheduler page.

$config->get_id();
$config->get_value("TodoId");

What method should I use to have access to the event ID?

Thanks in advance.

Osu

Hello,

‘onBeforeRenderSet’ event is executed only one time before ‘onBeforeRender’ and has no knowledge about events whatsoever. It’s use is rather limited and most common task for it would be adding new fields.
Probably you should use ‘onBeforeRender’ event though I missing how double-click on the event in the scheduler is connected to the events rendering.

Best regards,
Ilya

Well, I’m creating a personalized lightbox and need to replicate the “CrossOption” connector behavior. For that reason, I was told to use both “BeforeRender” and “BeforeRenderSet” events to add the necessary fields and populate them. My fields come in sets of 4 like this:

lstCC1
txtDateNotificationCC1
optDroitCC1
optNotificationCC1

The “1” at the end is a sequence number that will increase depending on how many people in CC I have. So, depending on which event the user opened, I need to add the fields dynamically to the object so that I can access them successfully. Here are the two functions I have so far. loadCC being bound to the “BeforeRender” event and prepareCC to the “BeforeRenderSet” event.


function loadCC($data)
	{
		$requete = "SELECT * FROM tblpmcc WHERE TodoId = " . $data->get_id();
		$resultat = mysql_query($requete);
		$indice = 0;
		
		while($ligne = mysql_fetch_array($resultat))
		{
			$indice++;
			$data->set_value("lstCC" . $indice, $ligne['NoPersonne']);
			$data->set_value("txtDateNotificationCC" . $indice, $ligne['CCDateNotification']);
			$data->set_value("optDroitCC" . $indice, $ligne['CCDroitPersonne']);
			$data->set_value("optNotificationCC" . $indice, $ligne['CCNotification']);
		}
		$data->set_value("CC_length", $indice);
		//$data->set_value("Bonjour", "11212");
	}
	
	function prepareCC($conn, $res, $config)
	{
		$requete = "SELECT * FROM tblpmcc WHERE TodoId = 23"; //this line is the whole problem
		$resultat = mysql_query($requete);
		$indice = 1;
		
		while ($indice <= mysql_num_rows($resultat))
		{
			$config->add_field("lstCC" . $indice);
			$config->add_field("txtDateNotificationCC" . $indice);
			$config->add_field("optDroitCC" . $indice);
			$config->add_field("optNotificationCC" . $indice);
			$indice++;
		}
		
		$config->add_field("CC_length");
	}

Have I been going about this all wrong? Should I try another approach entirely? I’ve tried adding the fields in the “BeforeRender” event but I remember not being successful since they wouldn’t show up later in the javascript code where I ultimately need them.

Anyway, thanks in advance

Osu

Hi, Osu.

I believe it would be better to move away from the idea of creating different number of fields for every event. You can create just 4 fields for your events, store all information there and then parse it on the client side.
I am not sure about meaning of your fields but hopefully the following example will make it clear.
Say you have an event with the following list of emails to send copy to: diana@example.com
Then on the server side you can fetch them all and ‘glue’ together — "test@example.com;andrew@example.com;diana@example.com" and then store that string in one field - event.copies.
On the client side you can split this string:

var copies = event.copies.split(';');

And now copies variable stores array with the full list of emails to send copy to.

Hope this helps.

Best regards,
Ilya

Thanks for the response… and now that I think about it, it makes more sense to do it your way than what I had in mind. Guess I just love complicated solutions lol.

Thanks again :slight_smile:

Osu