Hi Everyone,
I have 2 fields of type data.
Below is my code, which executes whenever I change the value in the field but I am not able to find the reason that why the second code runs only once I change the value in the textbox whereas the first runs every time I change the value in the textbox.
frappe.ui.form.on("Sales Order", "club_uf_mod_x_qty", function(frm, doctype, name)
{
msgprint("Mod X");
if(frm.doc.club_uf_mod_x_qty<0)
{
msgprint("Please enter a non-negative value");
cur_frm.set_value("club_uf_mod_x_qty",0);
cur_frm.refresh();
validated=false;
}
for (x = 0; x <clubuf_mod_x_data.length; x++)
{
var tbl = frm.doc.items || [];
var i = tbl.length;
//for(var i = 0; i < tbl.length; i++)
while (i--)
{
if(tbl[i].product_type == "CLUB (U.F.) - Mod ^")
{
cur_frm.get_field("items").grid.grid_rows[i].remove()
}
}
}
cur_frm.refresh();
clubuf_mod_x_data=[];
frm.trigger("club_uf_mod_x");
});
frappe.ui.form.on("Sales Order", "club_uf_mod_y_qty", function(frm, doctype, name)
{
msgprint("Test");
if(frm.doc.club_uf_mod_y_qty<0)
{
msgprint("Please enter a non-negative value");
cur_frm.set_value("club_uf_mod_y_qty",0);
cur_frm.refresh();
validated=false;
}
for (x = 0; x < clubuf_mod_y_data.length; x++)
{
var tbl = frm.doc.items || [];
var i = tbl.length;
while (i--)
{
if(tbl[i].product_type == "CLUB (U.F.) - Mod v")
{
cur_frm.get_field("items").grid.grid_rows[i].remove()
}
}
}
cur_frm.refresh();
clubuf_mod_y_data=[];
frm.trigger("club_uf_mod_y");
});
Any idea about this?
Regards
Ruchin Sharma