Friday 10 June 2016

[ERPNext] How to set property of field in child table?

How to set property of field in child table?

Ans: We can set property of doc fields using following syntax.

cur_frm.set_df_property(FIELDNAME, Property, Value);

e.g.

cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Entry");

We can also set property of fields in child table, which is the main reason for this post.

Syntax:

var df = frappe.meta.get_docfield("TABLE NAME","FIELDNAME", cur_frm.doc.name);
df.read_only = 1;



e.g.
var df = frappe.meta.get_docfield("Employer Project Details","company_name", cur_frm.doc.name);
df.options = ["Tech M", "Wipro", "TCS"];


Using above code, we have generated dynamic dropdown in child table field of Select type.


  


Please comment if you like this post or need any help.

Thanks,
Sambhaji Kolate

5 comments:

  1. wow...this is great...Exactly what i was looking for...Besides READ ONLY, what other properties can we set this way?

    ReplyDelete
  2. @Ruben Thanks for your comment.
    You can property mentioned in Customize form, like hide, make collapsible, set options for Select field, read_only or mandatory etc

    ReplyDelete