Hi all, I create a client script to handle batch description duplication. No same batch description is allowed ( From Stock > Batch )
frappe.ui.form.on(‘Batch’, {
validate(frm) {
if (frappe.db.exists('Batch', {'description': frm.doc.description}))
{
frappe.throw(__('Already exist, kindly provide a unique Batch Description'))
frappe.validated = false;
}
}
}
)
When I try to create a new batch, by entering the existing batch description to test the code, below error is displayed.
I did not found anything helpful regarding the error. Therefore I am seeking advise/helpful explanations for the above errors. What does it means? And did my code need amendment ? Kindly let me know. Any help is much appreciated.
Syntax error in query:
select `name`
from `tabBatch`
where `tabBatch`.`name` = {'description': 'F2102021-001'}
order by `tabBatch`.`naming_series` DESC
limit 1 offset 0
However where I tried to create new Batch with different Batch Description, its still unallowed me to do so. Can you point me where I should make the improvement in the code ?
If you mean from Customize menu option, I tried but below message is prompted :
I believe this is because there are already Batch with same Batch Description. Another cause of this custom validation is because we want to handle specific condition where same Supplier cannot have same Batch Description at 1 time.