Doctype1 - Motor
ChildTable1 - insurer_child
Doctype2 - Polciy
ChildTable2 - recipients
common field for both doctype is prospect_id
@rmehta @MartinHBramwell @trentmu @gsarunk Hi! I need to fetch values from insurer_child from Motor doctype and add it to the recipents table in Policy Doctype.
Thanks…
apart for @DaizyModi suggestion you can try this too
From the server side it is rather easy. if you are looking for client side script, first select the motor corresponding to the prospect of Policy and the get the child table values of obtained motor document like below. Once obtained you can add to the recipients table
frappe.call({
//you can also use frappe.client.get_value
"method": "frappe.client.get_list",
"args": {
"doctype": "Motor",
filters: {prospect_id:frm.doc.prospect_id},
fields: [ 'name',],
},
"callback": function(response) {
// response.message will be an array of motors. in this case we will get only
// record
console.log(response.message[0]);
frappe.call({
"method": "frappe.client.get_list",
"args": {
"doctype": "insurer_child",
"parent": response.message[0].name, //name of parent
fields: [ 'name','other_fields'],
},
"callback": function(response) {
console.log(response.message);
//iterate the response and add child in the frm
for .....{
frm.add_child('recipients', {
field1: value from iteration,
}
}
});
}
});
The above is just the approach. please fix the syntax and tailor it to your context. Hope this will help you
1 Like
@DaizyModi Thanks for your reply! .Will try this
@gsarunk Thanks for your effort & reply .I’m looking for the solution in Client side, will try this.
the above solution is for the client side only.
1 Like
There is a option of ‘get items from’ in the top left corner of doc type, you can fetch prom previous customized child table to current doc type !