How to bring a popup While clicking Approve and Reject button

Hi! I need a help.
@NCP
While Clicking the Approve and Reject button I need a popup wording.

frappe.ui.form.on('value',  {
    validate: function(frm) {
		if(frappe.confirm(frm.doc.workflow_state=="Approved By Sales Manager")){
			frappe.msgprint("Approve Clicked");
		}else if(frappe.confirm(frm.doc.workflow_state=="Reject")){
			frappe.msgprint("Reject clicked");
		}
},
});

This is my code, Which I have tried, but no notify is popping up.

This are the name of the status,

Hi @VINOTH,

First thing is, Do not tag any user.
The community is large if we have an answer to it then will reply to it.
Otherwise, anyone can answer you.

Please try it.

frappe.ui.form.on('Your DocType', {
    refresh: function(frm) {
        if (frm.doc.workflow_state == "Approved By Sales Manager") {
            setTimeout(() => {
                frappe.msgprint("Approved");
            }, 10);
	    } else if (frm.doc.workflow_state == "Rejected By Sales Manager") {
            setTimeout(() => {
                frappe.msgprint("Rejected");
            }, 10);	        
	    }
	}
});

Please set your doctype and workflow your according.

Thank You!

2 Likes

Thanks, It works!.
Thanks a lot :upside_down_face:

“Hi there, @NCP Is it possible to make the field mandatory prior to rejecting it?”

Hi @Krishn,

Yes you can.

Please check the syntax. so please try it.

frappe.ui.form.on('Your DocType', {
    validate: function(frm) {
        if (frm.doc.workflow_state == "Rejected By Sales Manager" && !frm.doc.required_field) {
            frappe.msgprint(__("Required Field is mandatory before rejecting."));
            frappe.validated = false;
        }
    },
    refresh: function(frm) {
        if (frm.doc.workflow_state == "Approved By Sales Manager") {
            setTimeout(() => {
                frappe.msgprint("Approved");
            }, 10);
        } else if (frm.doc.workflow_state == "Rejected By Sales Manager") {
            setTimeout(() => {
                frappe.msgprint("Rejected");
            }, 10);
        }
    }
});

Please set the doctype and field name your according to.

I hope this helps.

Thank You!

1 Like

Thank You,@NCP. I attempted this previously, but it didn’t work.

Alternatively, you can add a condition to your transition.