Adding text to event header

I am trying to add a character to the event header and what is happening is the result of the last event that is loaded is being placed on every event header.

i.e. if result is a red R then every event get a red R even if it should have a black R.

Any help would be appreciated.

I am running the following code in the  scheduler.templates.event_header = function(start,end,event){

				let redlinesExist = eventTopicRedlinesExist(event.topic_id);

				if (redlinesExist){
					console.log(event.id + "setting BLACK");
					sNewHeader += '  -  <font color="black"><strong>R</strong></font>';
				}else{
					console.log(event.id + "setting RED");
			    		sNewHeader += '  -  <font color="red"><strong>R</strong></font>';
				}

The below function checks if the topicID is in a database table.

function eventTopicRedlinesExist(topicID){	
			return new Promise((resolve, reject) => {
				$.ajax({
					type: "GET",
					url: "../endpoints/eventTopicRedlinesExist.php",
					dataType: "json",
					data: {"topicid": topicID},
					async: false,
					success: function (response) {
						var exists = false;
						$(".event-comment").remove();
						$(".not-avail").removeClass("not-avail");
						topicRedlinesExist = response;

						if(topicRedlinesExist.length > 0 && topicRedlinesExist[0].TRUE){

							exists = topicRedlinesExist[0].TRUE=='1';
						}else{
							exists = false;
						}
						resolve(exists);
					}, 
					error: function(xhr, textStatus, errorThrown) {
                        reject(false);
                    }
				});
			});
		}

Hello,

Unfortunately, Scheduler doesn’t support asynchronous code when using templates.

In your case, one of the options is to check the existing ID of the events before parsing or loading the events. You can then specify the additional property for each event based on the response received after the request.

Please check the example of how it might be implemented:
DHTMLX Snippet Tool ;

If you want to check the already parsed/loaded events, you can use the onParse event handler:
onParse Scheduler Docs ;

Please check the following snippet:
https://snippet.dhtmlx.com/g9qo7td6