Can't access frappe.session.user_fullname from custom.js

Hello. I’m trying to get frappe.session.user_fullname from a custom js in

I am using the user “Administrator” and this code to verify that it is getting the data correctly:

document.addEventListener("DOMContentLoaded", function () {
     var isAdmin = frappe.session.user_fullname === 'Administrator';

Always returns false. Instead, using only frappe.session.user_fullname from chrome console it returns result correctly

Any ideas? My goal is to hide some content taking the user (or the role) into consideration, but for some reason I cannot access the data from custom js.

Hi @jls:

Why not use frappe.session.user or

Hope this helps, bro.


I put frappe.session.user_fullname because it was what I was checking at the time (I had already tried it before, and multiple more variants xD), with frappe.session.user the result is the same:

document.addEventListener("DOMContentLoaded", function () {
     console.log("User:", frappe.session.user);

Output = “User: undefined”

With (I didn’t know about it), it seems to work:

document.addEventListener("DOMContentLoaded", function () {

Output: “User: Administrator”