Hello,
We can add Custom button in form to perform some actions.
Custom button:
Syntax:
cur_frm.add_custom_button(__("Show Info"), function() {
frappe.msgprint("Custom Information");
});
`
As custom buttons added in form inner toolbar, developer can have specific use-case to add custom button in Menu or action.
e.g Using action menu level custom button we can have dynamic workflow.
1) Adding custom action button, same as workflow actions.
e.g Approve By Account Lead
Syntax:
cur_frm.page.add_action_item(__("Approve by AR Lead"), function() {
frappe.msgprint("Approved");
cur_frm.trigger('approve');
});
Note: cur_frm.trigger will trigger frappe js code.
2) Adding menu button “Custom Print” in form menu.
Syntax:
cur_frm.page.add_menu_item(__("Custom Print"), function() {
frappe.msgprint("Printed Document");
cur_frm.print_doc();
});
3) Custom Action Icon similar to Print Icon for Email.
It will help end user to perform some action quickly and avoid unnecessary clicks.
Syntax:
cur_frm.page.add_action_icon(__("fa fa-envelope-o"), function() {
frappe.msgprint("Custom email or print");
new frappe.views.CommunicationComposer();
});
-
adding color on custom action icons
cur_frm.page.add_action_icon(__(“fa fa-envelope-o text-success”), function() {
frappe.msgprint(“email”);
new frappe.views.CommunicationComposer();
});cur_frm.page.add_action_icon(__(“fa fa-car text-warning”), function() {
frappe.msgprint(“get_doc_info”);
cur_frm.trigger(‘get_doc_info’);
});