Unable To Fetch Values From Single DocType in Client Script

Hi,

I am unable to get values from a custom Single Doctype. Here is the code. Is anything wrong?

cs = 'Custom Settings' ;    
frappe.db.get_single_value(cs,
            function(cs_doc) 
            {
                frappe.model.set_value(cdt, cdn, 'debit_acc',   cs_doc.def_acc_dr);
                frappe.model.set_value(cdt, cdn, 'credit_acc',  cs_doc.def_acc_cr);
            });

The following error occurs during execution of this code :

TypeError: validate_link() missing 1 required positional argument: 'docname'
    var cs = "Custom Settings";

    frappe.model.set_value(cdt, cdn, 'debit_acc',   frappe.db.get_single_value(cs, 'def_exp_misc_dr_acc'));
    frappe.model.set_value(cdt, cdn, 'credit_acc',  frappe.db.get_single_value(cs, 'def_exp_misc_cr_acc'));

Hi @pjoseph:

Can you ellaborate a little bit? Seems you are trying to use the values inside a child table row, but we need more context.

To get values, just use

value = frappe.db.get_single_value('Your single doctype', 'your_field')

Or settings = frappe.db.get_doc('Your single doctype') to get the entire document.

Sample:

frappe.db.get_doc('Custom Settings')
		.then(settings => {
			alert(settings["def_acc_dr"]);
		});

Hope this helps.

Thanks a lot @avc . It is working !!! Super !