Try ERPNext Buy Support Partners Foundation

How to hide child doc fields?

In my parent doc(Finished Goods) hava a select field with three options “Poly”, “Folding” and “Carton” and in Child doc(Finished Goods Child) have three fields “carton_no”, “size”, “quantity”.

I want if parent doctype field select Poly or Folding then hide “carton_no” field/div in “Finished Goods Child” doc.

Thanks in advance

Hello,

I am new to ERPNext, so please forgive me if my answer is wrong / not exactly what you need.
I would try to edit the carton_no field’s properties like in the picture below:


I named the the parent select field carton_type.

4 Likes

Hello,

Use below method:
cur_frm.fields_dict[child_table].grid.set_column_disp(field_name, condition);
For eg:

cur_frm.fields_dict[“items”].grid.set_column_disp(“custom_qty”, frm.doc.order_type==‘Sales’);

In sales order, if order_type is Sales then custom_qty in child table will display

For more details, kindly check stock_entry.js file https://github.com/frappe/erpnext/blob/master/erpnext/stock/doctype/stock_entry/stock_entry.js

Thanks, Rohit

Not working

Thank you for your effort

Trying … :slight_smile:

You can try :

cur_frm.fields_dict.child_table_field_name.grid.frm.cur_grid.fields_dict.carton_type.$wrapper.hide()

Sorry:
Please try this.

frappe.ui.form.on("Finished Goods Process Child", "finish_goods_process_child_add", function(frm) {
     if ('grid' in cur_frm.fields_dict.finish_goods_process_child) {
         var grid =  cur_frm.fields_dict.finish_goods_process_child.grid;         
         var interval = setInterval(function () {
             if ('cur_grid' in grid.frm) {
                 if(cur_frm.doc.typ != "Carton"){
                     grid.frm.cur_grid.fields_dict.carton_no.$wrapper.hide();
                 }else{
                     grid.frm.cur_grid.fields_dict.carton_no.$wrapper.show();
                 }
                 clearInterval(interval)
             };
         })
     };    
});

3 Likes

It works!
Thank you very much Mr Mainul :slight_smile:

Is this code supposed to be cahnged/written in a file on the server or put as a custom script? (sorry for the noob question, I’m still learning).

Yes, you need write this code in “doctype_file.js” on DocType Directory.

1 Like

Thank you!

@Aourongajab_Abir @sorin.negulescu

You can use eval:parent.carton_type==="Carton" in “Depends On” property of child fields “carton_no”.

3 Likes

Thanks

Thank you :slight_smile:

can i hide a specific item?

What is your usecase @Denmark_Del_Puso? Pls explain further.

eval:parent.update_stock===“0”

dear i am using this code to hide rate field depending on update stock but when i write this code in depend on field it completely disappear the rate field in the form but in list view it works fine.

Please help me on this and can anyone let me know to to write same code depending on item code

Hi @mainul
For every row of child table, Is it possible to hide/show a custom field when Item Code uom(Must be Whole Number) is selected.

can you give an Example?

Suppose to be, I have 2-items x and y. For item-x the uom(Must be Whole Number) is checked, so we should show custom_field in child table. For item-y the uom(Must be Whole Number) is unchecked, so we should hide custom_field in child table.