Fetch Child Table data from other DocType [Clientside]

DocType “UserAccounts” [fields: Account] is a Child Table of the “ManagerAccounts” [fields: User, Account] DocType

While I’m at the “Payment Entry” DocType I need to fetch data from “ManagerAccounts” DocType filtered by logged user and with data from child table.

I tried following code:

frappe.call({
    method:"frappe.client.get_list",
    args: {
        doctype:"ManagerAccounts",filters:{
                user: frappe.session.user}
    }, 
    callback: function(r) { 
        console.log(r.message);
    }
})

But it returns only

0: Object { name: "[ManagerAccounts Item Name]" }

How to fetch data stored within [ManagerAccounts Item Name] with ChildTable in it?

Managed it by myself:

frappe.call({
  method:"frappe.client.get_list",
  args: {
      doctype:"ManagerAccounts",
   filters:{
              user: frappe.session.user}
      },
  callback: function(r) {
   frappe.call({
       method: "frappe.client.get",
       args: {
           doctype: "ManagerAccounts",
           name: r.message[0].name
       },
       callback: function (ret){
           $(ret.message.account).each((index,element) => console.log(element.account));
           // Do things here
       }
   })
  }
})
2 Likes

I wanted to create another post about this but fortunately I found this.

I would love your help if it’s possible for this scenario: I created a new doctype called Guests which is filled in from the Event doctype as a table. The field “name” of the table is searchable and based on selecting an existing record, I would like specific fields to automatically fetch the data existing for that specific record.

Any idea how to do this ? :slight_smile:

Hello @Iulian_Olaru,

You’ll get hints from this .
Go through it!

Thanks & Regards,
Kalpit

Indeed but in my case the data fetched depends on the selection of the name field … I am confused on how to achieve this :slight_smile: