Item Atribute not showing in Sales Order

Hello,

Before the updates, the item attribute would automatically show on my sales orders.
For example:
Colour: BLACK

But now they are not anymore. I have tried to change the custom form by adding a custom field, but it does not fetch the information from my item code. Do you know how I could make it appear ?

Thank you !

Hi @helenelollipops

Did you checked description?

Collapsible View

Non Collapsible View

Hi Rohit,

Yes, I have checked the description box, but mine only has the item’s reference. I overwrote my items by importing a new csv, but I would like to know if there is another way to show my variant attributes.

Thank you for your reply.

Hi @helenelollipops,

Add custom field and write custom script to pull description value into custom field

custom script code

frappe.ui.form.on('Sales Order', {
	setup: function(frm) {
		frm.add_fetch('item_code', 'description', 'custom_field_fieldname');
	}
});

Hi @rohit_w,

Thank you for your reply and help. I really appreciate it.

I tried, but it did not work. Could you tell me if I did something wrong ? Because I do not know much about coding.

I added a custom field named “Attribute Value” in Sales order item right after the description field, and chose the field type as “data”, and created a custom script as below:

frappe.ui.form.on(‘Sales Order Item’, {
setup: function(frm) {
frm.add_fetch(‘item_code’, ‘description’, ‘item_attribute_value’);
}
});

Thank you !

You should put the script in Sales Order, so in custom script select Sales Order Doctype and paste it there.

Hi @helenelollipops

Try below code

frappe.ui.form.on('Sales Order', {
	setup: function(frm) {
		frm.add_fetch('item_code', 'description', 'attribute_value');
	}
});

I hope the fieldname of the “Attribute Value” is attribute_value(check custom field)

Hi @rohit_w ,

Thank you really much !
This has worked, but my problem is that my attributes are not in the description field, only my item’s reference. For example: 12345-BLACK is a variant of 12345, in the description field only “12345” appears.

So I tried to change your formula, but I encountered an error message.

frappe.ui.form.on(‘Sales Order’, {
setup: function(frm) {
frm.add_fetch(‘item_code’, ‘attributes’, ‘attribute_value’);
}
});

Hi @helenelollipops

attributes is the child table on the item master so above code will not work for it. You can only fetch the data of non table fieldtype.

You need to add the attributes table on the sales order doctype and have to write frappe.call to fetch the item’s attribuite and set on the sales order’s attribute table.

Thanks