How to fetch data and insert into table


I am creating a DocType for some internal requirement. I liked how the BOM could fetch operations and populate the table with values previously stored.

But I not able to replicate that fetch in a custom DocType. Basically I need to be able to auto load rows into a child table based on a template.

Also in DocType I noticed a fetch textbox. How can I use this, will it do what I require?

Is there some way to do this?

You may have to use custom scripts for this.

@Pawan This is perfect, thanks!
Quick question, will Custom Script Fetch Values From Master, bring a list or just a single record? Because I need to populate a table with a set of results.

For this example

Just a guess add_fetch here retrieves a single record

add_fetch usually retrieves one value/field from your master (field is the one specified in the arguments).

I think you’ll need to create a custom script (and maybe a python script) that fits the use case you’re trying to achieve. By the way , is this a custom app with a custom doctype/child table ? Or are you just adding a custom script to an existing ERPNext doctype?