Create Filtering Criteria in Doctype Child Table to fill Other Child table

Hi All, I’m newbie in ERPNext implementation…
I have case that need filtering something in my Doctype called “Custom Opportunity” that have 2 child table called “Filtering Criteria” and “Possible Asset”.
Filtering Criteria are the criteria to filter the DocType called “Custom Asset” based on some fields in those Custom Asset. For example, the filter are “capacity_used” “>=” “100”, so in the child table Possible Asset will show the list of Custom Asset that match filtering criteria.

Is it possible to do so with custom script?
I have several custom script implemented in other case, so any suggestion solution with custom script are very welcome.

Could someone give a bit guide how achieve that? Or someone who have bit similar case of those?
Thanks in advance

Found a bit similar case in here:

Populate child table with also filtering criteria…

frappe.ui.form.on("Doctype A",{
refresh: function(frm){   // I have used refresh you can use any trigger
        doctype:"Doctype B",
        filters: [
            ["field_a","=", frm.doc.field_a]  // You can set any filter you want
    		fields:["field_b","field_c"] // you can fetch as many fields as you want separated by a comma
		callback: function (response) {
    	if (response.message) {
        	$.each(response.message, function(i,row) {   // row can be anything, it is merely a name
        		    var child_add = cur_frm.add_child("child_table_DoctypeA");  // child_add can be anything
	        		child_add.child_table_field_a = row.field_b;
	        		child_add.child_table_field_b = row.field_c; // you can add as many fields as you want
          	        console.log(response.message);     // not really necessary just so you can view the message in the console to check for possible errors               


The filtering criteria based on field in parent doctype and the trigger I change to on button click…
This method is works. Now in my case I need the filtering criteria to be dynamic by adding those criteria to another child table “Filtering Criteria”, and when button “generate” clicked, it will automatically add “Possible Asset” based on item criteria.

If someone have an idea to modify code above to fit in my case, please kindly share…


1 Like

Share screenshots of the documents.