ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

How to hide child doc fields?


#1

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


#2

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.


#3

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


#4

Not working

Thank you for your effort


#5

Trying … :slight_smile:


#6

You can try :

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


#7

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)
             };
         })
     };    
});


Unable to hide custom field
#8

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


#9

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).


#10

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


#11

Thank you!


#12

@Aourongajab_Abir @sorin.negulescu

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


Hiding field in child form
#13

Thanks


#14

Thank you :slight_smile:


#15

can i hide a specific item?


#16

What is your usecase @Denmark_Del_Puso? Pls explain further.


#17

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


#18

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.


#19

can you give an Example?


#20

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.