Autofill table from database

I created a DocType called ‘File’, in which I have a form which consists of two columns - Invoice Number and Amount.

I want to add the Invoice Number and Grand Total of every entry in the Sales Invoice Database to this whenever I create a new File.

How can I do so in JS?

Don’t really understand the scope of that …you have all infos in Sales Invoice doctype …

@JoEz, my use case is that I want only the invoices of the last month. For example, if the current month is June, then I want the invoices of the month of May only.

@pranavgoel25 still i don’t understand …use filters to limit period

@JoEz, what I want to do is for the user to view all the sales invoices for the past month, and then when he/she clicks the ‘Save’ button, I take those invoices and send their data to another application.

Also, can filters be applied via the .js or the .py file?