How do I submit a Document using JS?

Hi! This is my code:

//previously I created "doc" with all filled fields
funcs = => {{
        method: "frappe.client.insert", //creating but it keeps only saved
        args: {
            doc: doc // doc object
        callback: function(r) {
        // here I need something to submit this doc (r)

How could I submit this “r”?
I didn’t find a function for this, did I miss something? :frowning:

Thanks in advance!

Try frm.submit(); not sure if the method exists.

I think you can also do,

frm.doc.docstatus = 1;;
1 Like

you will need to call again the submit method

callback: function(r){{
        "method": "frappe.client.submit",
        "args": {
              "doctype": res.message.doctype,

@schilgod Thanks for helping! But I didn’t figure how I could access the “frm” from each “r” for saving.

@max_morais_dmm Thanks too! To call a submit method again solved my issue.

Can you give me a tip on how to know better the available methods I could call? Is it through some documentation? Or reading the code on github?

@outerlook it was just an example, I did not realise you were submitting multiple docs. I think for your case @max_morais_dmm solution is perfect.

You need to browse the frappe app code to find out what methods are available, if you don’t find documentation. Try to search for frappe Developer cheatsheat.

1 Like

@schilgod there’s some files you can look for, but for the API, this is the best start place

But to know all methods you can call, you need to lookup all frappe and erpnext .py files, looking for functions decorated by @frappe.whitelist