Submit a document from different one

Hello,
I’m working on an opportunity workflow, and I wrote a client script that changes a value in the linked quotation document if the workflow status = Won so that quotation will be submitted.

I tried to change the database status and the docstatus as you see in the code below but i got this message “cannot edit standard fields”

// script in Opportunity form
after_workflow_action: function (frm) {

    // get the list of qutations 
    frappe.db.get_list('Quotation', {
        fields: ['name'],
        filters: {
            opportunity: frm.doc.name
        }
    }).then(records => {

        for (let i = 0; i < records.length; i++) {

            if (frm.doc.workflow_state == "Won") {
                frappe.db.set_value('Quotation', records[i].name, 'status', 'Open')
                    .then(r => {
                        frappe.db.set_value('Quotation', records[i].name, 'docstatus', 1)

                    })
            }

        }
    }
}

I don’t think you can submit a document with frappe.db.set_value. I don’t know your full use-case here, but this might be better as a server-side script.

If you really want to use a client-side script, you might use something like max’s solution here:

1 Like

I want to submit a quotation from the opportunity form and I don’t have access to the server-side, so I prefer using the client-side.
I have the ID name for the quotation document.

Can this way submit that other document?

Did you try the method in the link I posted? Unless I am misunderstanding your needs, it does exactly what you are looking for.