Hi,
I am trying to run a query on a child table field. The following are the details:
- Name of Child Table
item_variant_restrictions
- Name of parent doctype
item
- Name of field on which the query is to run
attribute
Now the attribute field in the child table should show only those attributes which are:
- Attributes which are NON-NUMERIC (where
numeric_values == 0
) - Attributes which are mentioned inside the table
attributes
of theItem
form.
To accomplish this I have a custom client side script as below:
cur_frm.cscript.custom_onload = function () {
if (cur_frm.doc.has_variants == 1) {
cur_frm.set_query('attribute', 'item_variant_restrictions', function(){
var attrs = []
cur_frm.doc.attributes.forEach(function(row){
attrs.push([row.item_variant_restrictions.attribute])
});
return {'filters': [['Item Attribute', 'attribute', 'in', attrs]]}
});
}
}
I am getting this error in the console
Uncaught TypeError: Cannot read property 'attribute' of undefined(anonymous function) @ VM698:331(anonymous function) @ VM698:330frappe.ui.form.ControlLink.frappe.ui.form.ControlData.extend.set_custom_query @ desk.min.js:7603$input.autocomplete.source @ desk.min.js:7593e.widget._search @ desk.min.js:11(anonymous function) @ desk.min.js:10e.widget.search @ desk.min.js:11(anonymous function) @ desk.min.js:10(anonymous function) @ desk.min.js:10n.extend.each @ jquery.min.js:2n.fn.n.each @ jquery.min.js:2e.widget.bridge.e.fn.(anonymous function) @ desk.min.js:10(anonymous function) @ desk.min.js:7587
Could I get a help on this script.