Where i can find the button function for adding
frappe.call{{ method
where i can find the method in the source code to add a call to my API when the button got clicked in Sales Order
NCP
May 21, 2024, 6:07am
2
Simple example:
Hi @umarless ,
Please review the syntax code, and I’ve tested it, and it functions correctly.
frappe.ui.form.on('Doctype A', {
refresh: function(frm) {
frm.add_custom_button(__('Cancel Document B'), function() {
cancelDocumentB(frm);
});
}
});
function cancelDocumentB(frm) {
var documentName = "A-2024-001";
frappe.call({
method: "frappe.client.cancel",
args: {
"doctype": "Doctype B",
"name": documentName
…
For more reference, check the sales_order.js, and find it.
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.cscript.tax_table = "Sales Taxes and Charges";
erpnext.accounts.taxes.setup_tax_filters("Sales Taxes and Charges");
erpnext.accounts.taxes.setup_tax_validations("Sales Order");
erpnext.sales_common.setup_selling_controller();
frappe.ui.form.on("Sales Order", {
setup: function (frm) {
frm.custom_make_buttons = {
"Delivery Note": "Delivery Note",
"Pick List": "Pick List",
"Sales Invoice": "Sales Invoice",
"Material Request": "Material Request",
"Purchase Order": "Purchase Order",
Project: "Project",
"Payment Entry": "Payment",
"Work Order": "Work Order",
This file has been truncated. show original
@NCP
But i have added the custom button already
Create Serial No
frappe.ui.form.on('Sales Order', {
custom_create_serial_no: function(frm) {
frappe.call({
method: "My method",
args: {
"name": frm.customer
},
callback: function(response) {
if (response.message) {
frappe.msgprint("Serial No created Successfully");
} else {
frappe.msgprint("Serial No created failed.");
}
}
});
}
do this work