Get the value saved for custom field

Hey, I have created a custom field in user setting doc for theme_color, a new column is there in DB in tabUser but i don’t know how to place that data in frappe.user object in JS.

frappe.get_doc("User", username).theme_color

or

frappe.db.get_value("User", username, "theme_color")

1 Like

I want it on front-end in JS not in python.

Solution i found:

Altered the query in frappe/frappe/utils/user.py in method load_user(self) line number 191

frappe.db.sql(“”“select email, first_name, last_name, email_signature, user_type, language, background_image, background_style, theme_color from tabUser where name = %s”“”, (self.name,), as_dict=1)[0]

now i can access that value from frappe.boot.user.theme_color in any JS file.

Thanks for your help @rmehta :slight_smile:

@ZainSajjad that is a bad solution. You should not edit frappe code, because you will not be able to upgrade.

Best to make a separate call like

frappe.call({
  method:"frappe.client.get_value", 
  args: {doctype:"User", name: user, field: "theme_color"}, 
  callback(r) { .. }
});
2 Likes

Done (y) Thanks :slight_smile: