How to Add Department Name in Employee Tree

I want to show department Name in Employee tree currently it show Employee name and Employee ID

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

Thanks zarrar

1 Like

Thanks for this topic, it helped us immensely with the new Animal Group DocType tree view for AgriNext! :muscle:t2: