Currently, the Item Description field is set to the Item Name + Attributes abbreviation by default when creating items. I want to use the attribute description (and/or any other field value) instead of abbreviations in the Item Description. How can I achieve this?
Hi @alphaomegaphi,
Possible, Use the “In Preview” feature.
Output:
I hope this helps.
Thank You!
1 Like
Hi @NCP It does help, thanks!
Now, it doesn’t work with Table fields. So, I ended up writing a custom script to add the attribute values to the description field. Here’s the code below if someone find it useful:
frappe.ui.form.on('Item', {
validate: function(frm) {
// Triggered when the Item form is validated (before saving)
updateItemDescription(frm);
}
});
function updateItemDescription(frm) {
// Construct the item description with attribute values
var item_description = frm.doc.item_name + ' / ';
frm.doc.attributes.forEach(function(attribute) {
// Access attribute value and append to the description
item_description += attribute.attribute_value + ' ';
});
// Update the item description field
frm.set_value('description', item_description);
}
2 Likes
Perfect, nice! But it only works when doing single variant, do you know the code for it to work also when generating multiple ?
I have not. I think for that your will need a server side script that look up the recently created variants an update the description field.
1 Like
After a few tries and research, i reached that conclusion too, thanks man