Hello All,
How to pass both parent table and child table values in a dictionary to pass it to a function and set in form.?
Here’s what i am trying to do,
From a POS like page call a function to get all the values from a doctype(parent and child) and set it in the page like parent and iterate child values to set as child similar to how you would set Customer (from -parent to parent) and items(from child table to child like table) in POS.
So far what i did :
call from .js
frappe.prompt([
{‘fieldname’: ‘name’, ‘fieldtype’: ‘Link’, ‘label’: ‘Select’,‘options’:‘options’, ‘reqd’: 1}
],
function(data){
frappe.call({
method: ‘method path’,
args: {
args: argds
},
}).then(r => {
if(r.message) {
console.log(r.message);
let dict = r.message;
console.log(dict.customer);
console.log(dict.child_items);
let some = dict.child_items; //first way
console.log(some.item); //returned undefined
for (var i in dict.child_items){ //second way
console.log(“child_items”+i.item); //returned undefined
}
.py
@frappe.whitelist()
def method(args):
doc = frappe.get_doc(“doctype”,args)
apt_dict ={
‘customer’: doc.customer,
‘child_items’: doc.child_table_name
}
frappe.errprint(apt_dict)
return apt_dict
what i get in console when i print the dict is the parent_doctype field and objects of child table rows.
Still cannot access.
any suggestions or alternate way to go about this ?
Thanks in advance.