Hi ERPNEXT community,
I’m trying to customise the Material Request Item for it to show the name of customer related to the Sales Order Number after I get the items from the Sales Order.
Basically it’s pulling a field from the Sales Order parent Doctype into a custom field in the child table Material Request Item.
Anyone has any suggestion for the script I should follow?
Test if this works by adding this script to the “material request item” doctype?
frm.add_fetch(‘sales_order’, ‘customer’, ‘your_custom_field_in_material_request_item_to_store_customer_name’);
thanks for the quick reply and help. The script you suggested didn’t work. However, I just figured out an easier way to pull the data.
- Create a custom field called Customer Name in the Material Request Item
- Data type: Data (Same as the data type in the field in Sales Order
- In Options enter: sales_order.customer_name
This fixes the problem beautifully. Because the sales_order field in Material Request Item is already linked to Sales Order, so I guess pull the data that’s linked to that doctype should be the same.
However, would you mind why “sales_order.customer_name” works in this case?
This is super. Never knew this would work. Will test it out. Logically it seems the right way to get this done.
Maybe others can help.
I am not sure why the other didn’t work. It should have fetched data upon the action of “Get items from sales order”.
I think because the the field for Customer is a Link field which seems similar to a Customer object. (If you have a look at the controller or Python code, Customer is a class) Just like in Python if you have an object you can access its attributes.
This should have been
frm.add_fetch(‘sales_order’, ‘customer**_name**’, ‘your_custom_field_in_material_request_item_to_store_customer_name’);