But in Contact there is also a child table for phone numbers.
In my custom doctype I have the fields for phone number.
How do I insert this phone number to the child table?
I also tried to use below script but I donât think it will work as it is new so there is no docname yet:
var p = frappe.model.add_child(docname, "Contact", "phone_numbers");
frappe.model.set_value(p.doctype, p.name, "phone", frm.doc.nomor_hp);
Hope this helps to sort the issue.
contact = frappe.new_doc(âContactâ)
contact.field = your field value
contact.append(âphone_nosâ, {
âphoneâ: âxxxxxxxxâ
})
contact.save()
That is for python. Instead of trying in js, py is better for creating a new_doc with child table details.
Pass the values from js as frm.doc and convert the json in py.