How to Add Department Name in Employee Tree

It won’t be possible out of the box.

Customization will be needed either on the frappe tree.js and employee query etc OR you can do a little javascript tweak in the employee_tree.js.
Here’s a sample tweak

	onrender(node) {
		let page = $(document);
		if(!node.is_root) {
			frappe.db.get_value("Employee", node.data.value, "department")
				.then((r) => {
					if(r.message.department){
						let x = page.find(`span[data-label="${node.data.value}"] .tree-label span.text-muted`);
						x.text(` ${ x.text() } ( ${r.message.department} )`);
					}
				})
		}
	}
2 Likes