Thank you so much @max_morais_dmm !!
Yes, earlier I have {Leave Application}
instead of “Leave Application
”. After your advice, I just removed brackets and tried in all possible way, clearing cache, bench update, bench migrate. But, still there is something we missing there.
At present, there is no console logs, no typo, still no dialog opening. Below is in Custom Script Section, by selecting document “Leave Application”. Do we need to update/upgrade script?
frappe.ui.form.on("Leave Application", "after_save", function(frm, cdt, cdn){
if (frm.doc.workflow_state && frm.doc.workflow_state.indexOf("Rejected") > 0){
frappe.prompt([
{
fieldtype: 'Small Text',
reqd: true,
fieldname: 'reason'
}],
function(args){
validated = true;
frappe.call({
method: 'frappe.core.doctype.communication.email.make',
args: {
doctype: frm.doctype,
name: frm.docname,
subject: format(__('Reason for {0}'), [frm.doc.workflow_state]),
content: args.reason,
send_mail: false,
send_me_a_copy: false,
communication_medium: 'Other',
sent_or_received: 'Sent'
},
callback: function(res){
if (res && !res.exc){
frappe.call({
method: 'frappe.client.set_value',
args: {
doctype: frm.doctype,
name: frm.docname,
fieldname: 'rejection_reason',
value: frm.doc.rejection_reason ?
[frm.doc.rejection_reason, frm.doc.workflow_state].join('\n') : frm.doc.workflow_state
},
callback: function(res){
if (res && !res.exc){
frm.reload_doc();
}
}
});
}
}
});
},
__('Reason for ') + frm.doc.workflow_state,
__('End as Rejected')
)
}
});