I have a child table that looks like this :
{
: : :
"fields": [
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": " Naming Series",
"options": "RTN-MOV-.########"
},
: : :
{
"allow_in_quick_entry": 1,
"fieldname": "from_stock",
"fieldtype": "Link",
"in_list_view": 1,
"label": "From Stock",
"options": "Warehouse",
"reqd": 1
},
: : :
{
"allow_in_quick_entry": 1,
"fieldname": "direction",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Direction",
"options": "Stock --> Cust\nCust --> Stock\nStock --> Stock\nCust --> Cust"
},
In the parent form I have:
frappe.ui.form.on("My Child", {
direction: (frm, cdt, cdn) => {
const d = locals[cdt][cdn];
frm.set_df_property('from_stock', 'reqd', 0);
frm.set_value('from_stock', warehouse);
d.set_value('from_stock', warehouse);
}
});
If I select a new option in direction
the handler is invoked.
My goal is to set/unset the ‘reqd’ attribute of ‘from_stock’, but I cannot see how to get the object in order to manipulate it’s attribute values.
The line…
frm.set_value('from_stock', warehouse);
… throws an error “Field from_stock not found.”
The line…
d.set_value('from_stock', warehouse);
… throws an error “TypeError: d.set_value is not a function.”
My questions are:
-
How can I alter the ‘reqd’ attribute of the ‘from_stock’ field of the child table?
-
More generally, How do I get the child form in order to manipulate its attributes?