Get Singles value in js

How do I get the value of a settings DocType like the paypal_settings on client side?
I know that the values are in tabSingles but when using frappe.db.get_value it tells me that the DocType “Singles” doesn’t exist.

1 Like

Hi you can try use frappe.db.sql("""select doctype,field, value from tabSingles""")

1 Like

Thanks for your reply, but I was asking how to get these values on the client side with javascript.

it is problem to you use from js and use my answer in python? and as I know in js is using this way frappe.model.get_value(doctype, name, fieldname); but I don’t think that it will work with Singles

You can do this

frappe.model.get_value('Print Settings', {'name': 'Print Settings'}, 'pdf_page_size',
  function(d) {

Thanks, but I was looking for a more inbuilt solution.

Thanks you, I’ll try this. Is there a way to get more values with one call?


frappe.model.get_list("Print Settings")
1 Like

This is not working for custom single DocTypes or singles like “Naming Series”.
Is there a way to prefill the js “locals” object with more DocTypes?

Try this:

var doctype = "Naming Series";
frappe.model.with_doc(doctype, doctype, function() {
var values = frappe.model.get_list(doctype);

This will throw an error when the current user doesn’t have the right permissions to view the DocType. Guess I will have to go with and use a custom sql statement.

This topic was automatically closed after 24 hours. New replies are no longer allowed.