I have create one custom data field and want to fetch user full name

I have create one custom data field and want to fetch user full name

@Rahul7218 check this How does the "Fetch From" in Doctype Custom Field work?

Hi @Rahul7218

Add client script

frappe.ui.form.on('Doctype Name', {
	onload(frm) {
		frm.set_value("fieldname", frappe.session.user_fullname);
	}
})

Thank you @Usama_Naveed
i have one question if i want to fetch specific role assign user full name then how?

@Rahul7218

In this case

frappe.ui.form.on('Doctype Name', {
	onload(frm) {
        if(frappe.user.has_role('System Manager')){
            frm.set_value("fieldname", frappe.session.user_fullname);
        }
	}
})

Put any role and it will return true or false
then get the full name and set it

1 Like

Thank you @Usama_Naveed