Hai,
How to generate QRcode for efficient tracking of an asset in erpnext
Step 1: Create a new Field type “HTML” and tick “In Preview” in Asset(Using Customization).
Step 2: Write a Client Script for DocType “Asset”.
Sample Client Script for Generating a QR Code using an API:
frappe.ui.form.on('Asset', {
refresh: function(frm) {
// Check if the asset has an ID (required for generating QR code)
if (frm.doc.name) {
// Generate QR code URL with asset ID
let qr_code_url = `https://quickchart.io/qr?text=${encodeURIComponent(frm.doc.name)}`;
// Set the custom HTML field with the QR code image
frm.set_df_property('custom_qr_link', 'options', `<img src="${qr_code_url}" alt="QR Code" style="max-width: 150px; max-height: 150px;">`);
}
}
});
Above code snippet will generate a QR Code for the Asset ID.
Note: The QR Code will be generated at the instance, doesn’t get saved in the Database.
1 Like