Pass arguments from one doc to another through custom client script/custom button

Hi,

Can you please guide me, how can i pass arguments from one doctype through custom button and when new form opens after user clicked the button, i should receive those arguments

I am currently setting up route_options while routing the user from one form to another, but I am getting undefined/null in console.

Here is the code :-1:

frappe.ui.form.on("Purchase Order", "refresh", function(frm) {
		frm.add_custom_button(__("Add Follow-up"), function() {
frappe.route_options = {"item_code": "TextCode"};
frappe.set_route("Form", "Item",frappe.model.make_new_doc_and_get_name('Item'));
		});

Hi @DME_Apaulsoftware,

Please apply it.

frappe.ui.form.on('Purchase Order', {
	refresh(frm) {
		frm.add_custom_button(__("Add Follow-up"), function() {
				frappe.route_options = {
					"item_code": "TextCode"
				};
				frappe.set_route("item", "new-item");
			});
	}
});

Then reload and check it, please.

Thank You!

Thanks,
It populated field, but how I check values in route_options in console, I am asking because there are some values which I need for further processing, and not for populating some fields, So can I check what I received other side when form rendered?

try this.

frappe.ui.form.on('Purchase Order', {
	refresh(frm) {
		frm.add_custom_button(__("Add Follow-up"), function() {
				frappe.route_options = {
					"item_code": "TextCode"
				};
                console.log(frappe.route_options.item_code);
				frappe.set_route("item", "new-item");
			});
	}
});
1 Like