Change Calendar Title bar Display

i tried to change calendar display title from event_calendar.js

frappe.views.calendar[“Event”] = {
field_map: {
“start”: “starts_on”,
“end”: “ends_on”,
“client”: “client”,
“id”: “name”,
“allDay”: “all_day”,
"title": “test”,
“status”: “event_type”,
“color”: “color”

},
style_map: {
“Public”: “success”,
“Private”: “info”
},
get_events_method: “frappe.desk.doctype.event.event.get_events”
}

but only allow change for standard fields not custom fields any ideasScreenshot-2017-11-2 Event Calendar

field_map parameters are for events.
You should fetch the field “test” from function

That is to change event titles. The calendar title is somewhere else.

Dear @oleg.k
Thanks for your help
but i don’t understand what what you mean about

but what i mean when i change title value

to any filed in the event doc for example “title”: “color”, it’s show normally on calendar title but that because the color is standard field but the customized field i add it to the document not working
what i need is get some information from event doc and display them on calendar title

Hi, @Alaa_Badri!

You mean to display them in event title in calendar? If so, then:

Here you tell calendar, that you want the title of the event to be the value of doc field “test”.

Here javascript is calling python function to get values of doc fields. The function is in frappe/desk/doctype/event/event.py file and the function name is get_events

Check it
You should add to sql statement “select” your custom field name to fetch

Cheers!
Oleg.

Dear @oleg.k
Thanks for your great guide i got it but now i need to display more than one field value but in the event_calendar.js have only one title statement how i can add more than one

Thanks in advance

@Alaa_Badri, you are welcome! I usually create a custom field (for example, named “calendar_title”) and when saving document filling field “calendar_title” with data from other fields. In event_calendar.js – “title”: “calendar_title”.

Oleg.

Dear @oleg.k
How you did

That is exactly what i need filling the field (description) from other three fields ( subject (standard field) - Client (custom field) - facilitator (custom field )

so how i can do that

Thanks in advance

As a variant - by custom script.

frappe.ui.form.on("Event", "validate", function(frm) {
	var custom_description = frm.doc.subject + "-" + frm.doc.client + "-" + frm.doc.facilitator;
	cur_frm.set_value("description", custom_description);
}
3 Likes

Dear @oleg.k
Thanks a million it’s an awesome script
but if when add fields goes to second line not in the same line and change it’s font and color

@Alaa_Badri, you are welcome. It is a simple script. As for changing colours in calendar, I have some issues in frappe v9.1.10. In my installation calendar understands only field “color”. “color_map”, “style_map” and “get_css_class” are not working for me. Don’t know why. So maybe someone else can help you. Sorry.

Oleg.

Okay Thanks a gain for your help if you got any update please send to me

Dear @oleg.k
i try to apply this script on filed type Table not return value its only return this

[object Object]

do you have any suggest

Dear @oleg.k

Any update

@Alaa_Badri, Hi!

Table field needs another doctype in it’s Options. It is hard to understand your purpose and problem without detailed information.

Dear @oleg.k

Thanks for your response
my purpose is put field values for ( course name , client , facilitator ) int Description field to display it as a title for calendar like we did before with your script but i change facilitator doc type to table to able add more than one facilitator in one Event but i got wrong value in Description field

Dear @oleg.k
Any Update

Dear @Alaa_Badri, sorry for long reply – I didn’t get the notification of your question. if you still need the answer (or for others who also need):
The Table field is an array. You should loop through the table field.

frappe.ui.form.on("Event", "validate", function(frm) {
    var facilitators = "" ;
    for (item in frm.doc.facilitator) {
        facilitators += frm.doc.facilitator[item].facilitator + "-"; // last "facilitator" in frm.doc.facilitator[item].facilitator is the name of the field of Table Doc
    }
    facilitators = facilitators.slice(0, -1); // remove last delimiter "-"
    var custom_description = frm.doc.subject + "-" + frm.doc.client + "-" + facilitators;
    cur_frm.set_value("description", custom_description);
 }

Hope this helps.