Filter Window default customization

Are Filter Windows’ default values customizable?

For example:

When creating a New Payment Entry:
Once we click on the “Get Outstanding Invoice” button under Reference section, I would like the defaults to be:

  • Posting Date = Null
  • Due Date = From Date = 01-01-2023; To Date = Today
  • Allocate Payment Amount (Checkbox) = Unchecked.

Hi @dfranco,

We configure like first do hide the button of Get Outstanding Invoice.
Then create a custom button like Get Outstanding Invoice Custom.
Custom button field name: get_outstanding_invoice_custom

Then apply custom/client script for it.

frappe.ui.form.on('Payment Entry', {
	get_outstanding_invoice_custom: function(frm) {
		const today = frappe.datetime.get_today();
		const from = "2023-01-01";
		const fields = [
			{fieldtype:"Section Break", label: __("Posting Date")},
			{fieldtype:"Date", label: __("From Date"),
				fieldname:"from_posting_date", default:from},
			{fieldtype:"Column Break"},
			{fieldtype:"Date", label: __("To Date"), fieldname:"to_posting_date", default:today},
			{fieldtype:"Section Break", label: __("Due Date")},
			{fieldtype:"Date", label: __("From Date"), fieldname:"from_due_date"},
			{fieldtype:"Column Break"},
			{fieldtype:"Date", label: __("To Date"), fieldname:"to_due_date"},
			{fieldtype:"Section Break", label: __("Outstanding Amount")},
			{fieldtype:"Float", label: __("Greater Than Amount"),
				fieldname:"outstanding_amt_greater_than", default: 0},
			{fieldtype:"Column Break"},
			{fieldtype:"Float", label: __("Less Than Amount"), fieldname:"outstanding_amt_less_than"},
			{fieldtype:"Section Break"},
			{fieldtype:"Link", label:__("Cost Center"), fieldname:"cost_center", options:"Cost Center",
				"get_query": function() {
					return {
						"filters": {"company": frm.doc.company}
					};
				}
			},
			{fieldtype:"Column Break"},
			{fieldtype:"Section Break"},
			{fieldtype:"Check", label: __("Allocate Payment Amount"), fieldname:"allocate_payment_amount"},
		];

		frappe.prompt(fields, function(filters){
			frappe.flags.allocate_payment_amount = false;
			frm.events.validate_filters_data(frm, filters);
			frm.doc.cost_center = filters.cost_center;
			frm.events.get_outstanding_documents(frm, filters);
		}, __("Filters"), __("Get Outstanding Documents")).hide();
	}
});

Then reload and check it.
Maybe it will become helpful for you.

Thank You!

2 Likes

This worked perfectly!
Learning so much on the custom client scripts.

Thank you!