How to show various DocTypes in one Calendar view

Thank you avc for taking the time to explain the workflow in such detail. You help a newbie with rapid steps forward!

As for the sql query, of course, the exact field names must be specified. Sad that I didn’t realize that myself. So I modified it based on your example.

I first copied the custom script exactly from your example:

frappe.views.calendar["TFS Combi View"] = {
	field_map: {
		"start": "exp_start_date",
		"end": "exp_end_date",
		"title": "subject",
		"eventColor": "color"
	},
	gantt: true,
	
	get_events_method: "the_factory_suite.events.get_events.get_events"
}

I then also modified the .py file, initially exactly as you specified it:

import frappe

@frappe.whitelist()
def get_events():
	"""Returns events for Gantt / Calendar view rendering.
	"""
	
	data = frappe.db.sql("""
		SELECT CONCAT('Event: ', subject) as subject, '#FF5733' as color, starts_on as exp_start_date, ends_on as exp_end_date FROM `tabEvent` UNION SELECT CONCAT('Task: ', subject) as subject, '#86F95C' as color, exp_start_date as exp_start_date, exp_end_date as exp_end_date  FROM `tabTask` UNION SELECT CONCAT('Leave application: ', employee_name) as subject, '#5CA8F9' as color, from_date as exp_start_date, to_date as exp_end_date FROM `tabLeave Application`
		""", as_dict=True)
	return data

i then ran a bench clear cache and a bench clear website cache

But strangely enough, I can’t see the newly created “TFS Combi View” calendar anywhere. So I can’t check if I’m getting anywhere or not.

So I have some extra questions raising:

I have the Custom Script residing under Task-List. Am I wrong to expect to see an extra line in the Calendar Menu called TFS Combi View? Like here somewhere:


That would be the idea, and in an ideal world, we would have a custom shortcut button on the Home Page that brings us directly to this combined view.

I’m definitely missing something to have this new view available in Calendar. Still, crawling the web for extra info I don’t manage to find some explanation or tutorial to figure out this primary step.

As you have a screenshot of a calendar exactly working as it is supposed to be in the combined view, (including very personalized events!!!) maybe you can point out to me how you did that…

I am already very grateful for all the effort you have made to help me!

Little note on the side, the console did not work on our self-hosted system - it always returned a syntax error. I went to look in the respective Event, Task and Leave Application details for the relevant field names.