How to show warning message before submit sales invoice

Hi,

I need to create a frappe warning message is appear to the user after clicking submit, but the submitting process depends on what is selected, if (Yes) the complete process if (No) stop the submitting process.

I searched for before_workflow_action but as I searched it used doctype that uses Workflow doctype and I didn’t use workflow in my sales invoice

Has anyone had this case before?

@NCP can you help me in this case

Any help ?

Please check before_submit controller hook. More information [here].(Controllers)

Yes, am already use the below code

	before_submit:function(frm){
		frappe.confirm(
			'Are you sure to complete this process?',
			function(){
				window.close();
				// continue with submit process
			},
			function(){
				// reject submit process
			}
		)
		
	}

but is not working as I want

any help ?

Thank you man
@peterg

    before_submit: async (frm) => {
        let prompt = new Promise((resolve, reject) => {
            frappe.confirm(
                'Are you sure?',
                () => resolve(),
                () => reject()
            );
        });
        await prompt.then(
            () => frappe.show_alert("Submitted", 3), 
            () => {
                frappe.validated = false;
                frappe.show_alert("Not submitted", 3)
            }
        );
    }