Hi Everyone,
Below is the custom script that I have used for BOM I wanted that if an item is not approved (as per custom workflow) it should not allow user to select the same in BOM.
It is working fine, but it works only once. Once it shows error and after that if user selects any other item it does’t get populated with all the details of the item. Even I have tried by putting a message but found that that the entire block works only once.
Any idea on this?
frappe.ui.form.on("BOM", "item", function(frm) {
cur_frm.add_fetch('item','workflow_state','item_workflow_state')
if(frm.doc.workflow_state!="Approved")
{
msgprint("Test");
cur_frm.set_value("item", "");
cur_frm.set_value("item_name", "");
refresh_field("item");
frappe.throw("You cannot select an item which is not approved!");
}
});
Regards
Ruchin Sharma