I am looking to find a way have set defaults depending on User Selection.
One of the aspects I want to implement this is for Items Creation. Our company sells many items and sometimes the item attributes is different depending on the item. I want to have the Item Attribute to be preselected depending on the Item Groups. Is there a way to do that?
I guess you will have to write client script to achieve this.
I think so too. Just wanted some guidance on how to script it. Any help would be great. I think server script would be more applicable right?
you can use this simple client script.
frappe.ui.form.on('Item', {
item_group: function(frm) {
if (frm.doc.item_group === 'Products') {
// Clear existing attributes
frm.clear_table('attributes');
// Add the 'Color' attribute
let child = frm.add_child('attributes');
child.attribute = 'Color';
// Refresh the attributes field to reflect the change
frm.refresh_field('attributes');
}
}
});
you need add more details to this to make it more customised