Auto Submit Button on Status Sales Invoice Status Draft

Hello Folks,

I am trying to use custom script in which I want my system to submit invoice automatically when status==Draft. Below sample code for reference. Can anyone help me out in this case.

frappe.ui.form.on(‘Sales Invoice’, {
before_save(frm) {
if( status==‘Draft’ )
{
alert(‘Form is submitting…’);
document.getElementById(“form”).submit();
}
}
});

Kind Regards,
Saad

Hi @Syed_Saad_Imam,

Please apply it.

frappe.ui.form.on('Sales Invoice', {
	before_save(frm) {
		if (frm.doc.status == "Draft") {
		    frappe.msgprint("Form is submitting…");
		    frm.save('Submit');
		}
	}
});

Then reload and check it.

Thank You!

1 Like

Much appreciated @NCP

Thanks, man it works fine now for me. If I need any further assistance will ping you again.

Regards,
Saad

Dear @NCP Issue is when I’m trying to send a Sale Invoice through API in that case it is not submitting the record auto. With manual creating sales, Invoice is fine. Can you suggest?

Thank you in advance.

Share your script or api … forum users will help you.