Warning for End of Life Products

When selecting products which have passed the end of life date, the system will display a prompt to warn the users. This is my current script but it is not working.

frappe.ui.form.on("Quotation Item", "end_of_life", function(frm) { if (frm.doc.items.end_of_life < get_today()) { msgprint("You can not select past date in From Date"); validated = false; } });

end of life date is located in Quotation Item table.

please help!

I dont think that quotation item table has end of life fields… did you insert that field?

Yes, I have already inserted that field and the “End of Life” is field is populated as above screenshot.However, the script is not working.

Hi @Justin_Lu,


here frm.doc.items is the list of Quotation Items, you will need the object of current items then only you can get the valid end_of_life value.

please try,

frappe.ui.form.on(“Quotation Item”, “end_of_life”, function(frm, cdt, cdn) {
item = locals[cdt][cdn];
if(item.end_of_life < get_today()){
// js code

Thanks, Makarand

1 Like