Hi everyone,
I wanted to clarify a point about fetching field values from documents in Frappe client-side JavaScript.
I’ve been wondering:
Is
frappe.db.get_value()wrong? Actually, in JavaScript, isn’t it the most efficient way to fetch one or a few fields from a document?
From my understanding:
-
frappe.db.get_value(doctype, name, fieldname)is lightweight and directly fetches only the needed field(s). -
frappe.call({ method: "frappe.client.get", ... })is more flexible but heavier since it returns the full document. -
Using
frappe.db.get_valueis particularly efficient if you only need one or a few fields, and you can add caching to avoid multiple server hits for the same document.
I’d love to hear from the community:
-
Do you prefer
frappe.db.get_valueorfrappe.callin client scripts? -
Are there situations where
frappe.callis a better choice even for a single field?
Thanks in advance for your insights!