I added a child table in Sales Order doctype called Container List which captures a list of containers related to each sales order. From the Sales Order, a Project connected to the Sales Order is created and in this, a user can create multiple tasks in relation to the delivery of these Containers. To achieve this, I would want the linked field for Container No. to be filtered to only show the containers which we earlier created in the Container List child table in Sales Order.
I have written this client script and I can see that the sales_order is being picked, however the filter is not being applied.
frappe.ui.form.on('Task', {
refresh: function(frm) {
// Check if the Project has a Sales Order linked to it
if (frm.doc.project) {
frappe.call({
method: 'frappe.client.get_value',
args: {
doctype: 'Project',
filters: { name: frm.doc.project },
fieldname: 'sales_order'
},
callback: function(response) {
var sales_order = response.message.sales_order;
console.log(sales_order);
if (sales_order) {
frm.set_query('custom_container_number_ref', function() {
return {
filters: {
parent: sales_order
}
};
});
}
}
});
}
}
});
Any help would be greatly appreciated.