Is it possible to set a filter like more than Now() or more than Today?

I would like to see upcoming events. So I was thinking of setting the filter to “Date >= Now()”

Unfortunately it seems that it is only possible to use “timespan”. But “timespan” does not seem to allow “more than” or “less than”.

Need advice on how to achive “Date >= Now()” in the filter section.

You can use the listview client script for that according to the scenario.

Please check it.

frappe.listview_settings['Event'] = {
    onload: function(listview) {
        frappe.route_options = {
    		"starts_on": ['>=',frappe.datetime.get_today()]
    	};
    }
};

Output:

When reloading the page then filter will set automatically.

Cool! Let me try it out.

Thank you for replying and for the code.

The code works great for “today”. Thank you again for helping.

frappe.listview_settings['Event'] = {
    onload: function(listview) {
        frappe.route_options = {
    		"starts_on": ['>=',frappe.datetime.get_now()]
    	};
    }
};

Tried the above with “get_now()” but it does not seem to work.
Is the “get_now()” correct? Or it should be something else?

frappe.listview_settings['Event'] = {
    onload: function(listview) {
        console.dir(frappe.datetime);
        frappe.route_options = {
    		"starts_on": ['>=',frappe.datetime.now_datetime()]
    	};
    }
};

It should have been “now_datetime”. It is working great!

Once again thank you for helping. I do appreciate it.

1 Like