Get current user email on template

How can I get current user email on my quotation print template?

Like {{ frappe.session.user_email }}

Solved.

{{ frappe.db.get_value("User",{"name":frappe.session.user}, "email") }}

2 Likes

Dear @Leonardo_Augusto
how to do that as JV script to get user email into filed in sales order doc

Hello @Alaa_Badri

Keep the below code in refresh event of Sales Order for getting the current user email in to a field.

if(frm.doc.owner != undefined){
			frappe.call({
				method:"frappe.client.get_value",
				args:{
					"doctype":"User",
					"filters":{
						"name":frm.doc.owner
					},
					"fieldname":["email"]
				},
				callback: function(userEmail){
					if(userEmail.message != undefined){
						cur_frm.set_value("user_email",userEmail.message.email);
						cur_frm.refresh_fields("user_email");
					}
				}
			})
		} 

The new field name in Sales Order is “user_email” for setting the email of a user in this field.
This is how we can do within the js part of the code. I hope it is useful for you.

Thanks & Regards,
Kalpit Shah

Thank your You Save my Life