Skip to content

Instantly share code, notes, and snippets.

View munir131's full-sized avatar
:octocat:

Munir Khakhi munir131

:octocat:
View GitHub Profile
@munir131
munir131 / Supplier_UID.js
Created October 6, 2022 10:47 — forked from karthikeyan5/Supplier_UID.js
Collection of some Frappe framework custom script
// Here, Supplier DocType Contains a custom field (readonly) Called "UID".
// This feild is auto populated with the next number based on the highest UID in the supplier table.
frappe.ui.form.on("Supplier", {
validate: function(frm) {
if(frm.doc.__islocal == '1'){
frappe.db.get_list("Supplier", {fields:'uid', order_by:"uid desc",limit:1}).then((data) => {
frm.set_value("uid",String(parseInt(data[0].uid)+1).padStart(5,'0'));
});
}