Set Calendar Event Topic Attribute Programmatically

Hi again.
I have a block that creates a calendar event. I need to also set a topic attribute upon creation. It doesn’t seem to use the same process as setting a page attribute.

$event = Event::getByID($eventID);
$item0 = TopicTreeNode::getNodeByName('Room 1 Queen');
$event->setAttribute('room_type', array($item0->getTreeNodeDisplayPath())); 

I get an error that setAttribute was called on NULL.
Any thoughts on what I am doing wrong?

So I found a reference to how to get the Event object so that explains why I was getting the error of setAttribute on NULL

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$service = $app->make(EventOccurrenceService::class);
$occurrence = $service->getByOccurrenceID($eventID);

but the setAttribute call still doesn’t do its thing… no errors or anything, it just doesn’t set the attribute.

Did you ever make any progress on this? I also am trying to get and set attributes programmatically, and it’s not working the way that it does for pages.

I’ve even managed to get the correct version and a currency. But when I call get attributed on it. It doesn’t recall the attribute value that I See when I edit an event.

I didn’t actually. It was more of an optional project and I abandoned it. I did manage to be able to GET the attribute, just not SET it.

Here is the code I was monkeying with. It basically checks if the dates a user selected are open and what room type is available. Not sure if it will help you but you are welcome to it.

	public function action_checkDates(){
		$topics = $this->getTopics('Rooms');

		$availableTopics = $topics;
		$nsTime = strtotime($_POST['startdate']);
		$neTime = strtotime($_POST['enddate']);
		$list = new EventOccurrenceList();
        $calendar = $this->getCalendarOrCalendars();
        if (is_object($calendar)) {
            $permissions = new \Permissions($calendar);
            $this->set('canViewCalendar', $permissions->canViewCalendar());
		if ($calendar) {
			$results = $list->getResults();
		$events = $results;
    	$service = Core::make('helper/date');
    	if (count($events)>0) {
			foreach ($events as $occurrence) {
				$rtobj = $occurrence->getAttribute('room_type');
				if ($rtobj) {
					$rt = $rtobj[0]->getTreeNodeDisplayName();

					$sMonth = $service->formatCustom('m', $occurrence->getStart()); //Numeric Month
					$sYear = $service->formatCustom('Y', $occurrence->getStart()); //Full Year
					$sDay = $service->formatCustom('d', $occurrence->getStart()); //Numeric Day

					$eMonth = $service->formatCustom('m', $occurrence->getEnd()); //Numeric Month
					$eYear = $service->formatCustom('Y', $occurrence->getEnd()); //Full Year
					$eDay = $service->formatCustom('d', $occurrence->getEnd()); //Numeric Day

					$sReg = $sYear.'-'.$sMonth.'-'.$sDay;
					$eReg = $eYear.'-'.$eMonth.'-'.$eDay-1;

					$sTime = strtotime($sYear.'-'.$sMonth.'-'.$sDay);
					$eTime = strtotime($eYear.'-'.$eMonth.'-'.$eDay)-86400;

					if($nsTime >= $sTime && $nsTime <= $eTime ||
					   $neTime > $sTime && $neTime < $eTime ||
					   $sTime > $nsTime && $sTime < $neTime ||
					   $eTime >= $nsTime && $eTime <= $neTime ){
						foreach($availableTopics as $subKey => $subArray){
							  if($subArray['name'] == $rt){

		foreach($availableTopics as $at) {
		echo json_encode($atarray);