Frm.trigger() with parameters

Can we pass additional parameters to frm.tigger functions? I need to call the same function with just one different argument but I have to repeat the code. Is there a way to pass arguments to them?

1 Like

you got any solution?

No didn’t

@Khadija, you can use frm.events in place of frm.trigger to pass extra parameter.

For Example:
frm.events.invoke_doc_function(frm, “populate_matching_invoices”);

3 Likes

Hello Khadija,

You can add the desired attribute to the form object for example

frappe.ui.form.on('DOCTYPE NAME', {
	refresh: function(frm) {
		frm.foo = 'baz';
		frm.trigger('load_fields_options');
	},
	load_fields_options: function (frm) {
		console.log('frm.foo: ', frm.foo);
    }
}