using frappe.session.user will only give emailid of the logged in user but I want full_name and username also. Is there any function for that in frappe
Hi.
You can get the full name using frappe.session.user_fullname
its not working
Sorry, I may have misunderstood you. A little more information…
If you are trying to get that data through js in the web form, you can try this:
frappe.ready(function () {
// Get the ID of the current user
var user_id = frappe.session.user;
// Call Frappe's API to get user details
frappe.call({
method: 'frappe.client.get',
args: {
doctype: 'User',
name: user_id
},
callback: function (data) {
if (data.message) {
// Extract the user's full name from the full_name field and the user's username from the username field.
var full_name = data.message.full_name;
var user_name = data.message.username;
// Display the user's full name in the console
console.log("User name of user:", user_name);
console.log("Full name of user:", full_name);
}
}
});
});
Output:
Thank you