Cannot access fields added using Customize (Ctrl+J) in Client Script. Why?

Hello,

I have customized (using Ctrl+J) Purchase Receipt Item and added a few extra fields to it.

Here is the JSON of Purchase Receipt Item.

{
 "custom_fields": [
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 0,
   "allow_on_submit": 1,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-07-25 19:37:22.808789",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": "item_code.gst_hsn_code",
   "fetch_if_empty": 1,
   "fieldname": "gst_hsn_code",
   "fieldtype": "Data",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 22,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "description",
   "label": "HSN/SAC",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-07-25 19:37:22.808789",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-gst_hsn_code",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 1,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 0,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-07-25 19:37:22.928925",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": "item_code.is_nil_exempt",
   "fetch_if_empty": 0,
   "fieldname": "is_nil_exempt",
   "fieldtype": "Check",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 23,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "gst_hsn_code",
   "label": "Is Nil Rated or Exempted",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-07-25 19:37:22.928925",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-is_nil_exempt",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 1,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 0,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-07-25 19:37:23.099575",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": "item_code.is_non_gst",
   "fetch_if_empty": 0,
   "fieldname": "is_non_gst",
   "fieldtype": "Check",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 24,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "is_nil_exempt",
   "label": "Is Non GST",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-07-25 19:37:23.099575",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-is_non_gst",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 1,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": "",
   "columns": 0,
   "creation": "2022-09-09 12:39:23.167952",
   "default": null,
   "depends_on": "",
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "wire_coil_details",
   "fieldtype": "Section Break",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 8,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "item_name",
   "label": "Wire Coil Details",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 12:39:23.167952",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-wire_coil_details",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 12:39:24.300781",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "coil_id",
   "fieldtype": "Data",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 9,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "wire_coil_details",
   "label": "Coil ID",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 12:39:24.300781",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-coil_id",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 12:39:25.481182",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "supplier_code",
   "fieldtype": "Data",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 10,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "coil_id",
   "label": "Supplier Code",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 12:39:25.481182",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-supplier_code",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 12:39:26.568232",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "material_specs",
   "fieldtype": "Data",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 11,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "supplier_code",
   "label": "Material Specs",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 12:39:26.568232",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-material_specs",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 12:39:27.740896",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "coil_inward_date",
   "fieldtype": "Date",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 12,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "material_specs",
   "label": "Coil Inward Date",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 12:39:27.740896",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-coil_inward_date",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 12:39:28.866926",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "column_break_12",
   "fieldtype": "Column Break",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 14,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "coil_heat_no",
   "label": null,
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 12:39:28.866926",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-column_break_12",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 15:49:06.445040",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "coil_batch_no",
   "fieldtype": "Data",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 15,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "column_break_12",
   "label": "Coil Batch Num",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 15:49:06.445040",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-coil_batch_no",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 1,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 15:50:40.657107",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "coil_qty",
   "fieldtype": "Int",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 16,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "coil_batch_no",
   "label": "Coil Qty",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 15:50:40.657107",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-coil_qty",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 15:50:42.096144",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "coil_wt",
   "fieldtype": "Float",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 17,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "coil_qty",
   "label": "Coil Wt(Kg)",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 15:50:42.096144",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-coil_wt",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "3",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 1,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-09 15:51:53.772966",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "wire_size",
   "fieldtype": "Float",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 18,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "coil_wt",
   "label": "Wire Size (mm)",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-09 15:51:53.772966",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-wire_size",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "2",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 0,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-10 12:05:19.998132",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "coil_heat_no",
   "fieldtype": "Link",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 13,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "coil_inward_date",
   "label": "Coil Heat Num",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-10 12:05:19.998132",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-coil_heat_no",
   "no_copy": 0,
   "non_negative": 0,
   "options": "Batch",
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  },
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "allow_in_quick_entry": 0,
   "allow_on_submit": 0,
   "bold": 0,
   "collapsible": 0,
   "collapsible_depends_on": null,
   "columns": 0,
   "creation": "2022-09-24 15:42:30.640819",
   "default": null,
   "depends_on": null,
   "description": null,
   "docstatus": 0,
   "dt": "Purchase Receipt Item",
   "fetch_from": null,
   "fetch_if_empty": 0,
   "fieldname": "qc_passed",
   "fieldtype": "Check",
   "hidden": 0,
   "hide_border": 0,
   "hide_days": 0,
   "hide_seconds": 0,
   "idx": 18,
   "ignore_user_permissions": 0,
   "ignore_xss_filter": 0,
   "in_global_search": 0,
   "in_list_view": 0,
   "in_preview": 0,
   "in_standard_filter": 0,
   "insert_after": "wire_size",
   "label": "QC Passed",
   "length": 0,
   "mandatory_depends_on": null,
   "modified": "2022-09-24 15:42:30.640819",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-qc_passed",
   "no_copy": 0,
   "non_negative": 0,
   "options": null,
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "permlevel": 0,
   "precision": "",
   "print_hide": 0,
   "print_hide_if_no_value": 0,
   "print_width": null,
   "read_only": 0,
   "read_only_depends_on": null,
   "report_hide": 0,
   "reqd": 0,
   "search_index": 0,
   "translatable": 0,
   "unique": 0,
   "width": null
  }
 ],
 "custom_perms": [],
 "doctype": "Purchase Receipt Item",
 "property_setters": [
  {
   "_assign": null,
   "_comments": null,
   "_liked_by": null,
   "_user_tags": null,
   "creation": "2022-09-09 15:59:51.002678",
   "default_value": null,
   "doc_type": "Purchase Receipt Item",
   "docstatus": 0,
   "doctype_or_field": "DocField",
   "field_name": "item_code",
   "idx": 0,
   "modified": "2022-09-09 15:59:51.002678",
   "modified_by": "Administrator",
   "name": "Purchase Receipt Item-item_code-allow_in_quick_entry",
   "owner": "Administrator",
   "parent": null,
   "parentfield": null,
   "parenttype": null,
   "property": "allow_in_quick_entry",
   "property_type": "Check",
   "row_name": null,
   "value": "1"
  }
 ],
 "sync_on_migrate": 1
}

In my custom app I have following code in hooks.py

doctype_js = {"Purchase Receipt" : "public/js/purchase_receipt.js"}

In the file purchase_receipt.js I have following code to validate

frappe.ui.form.on('Purchase Receipt', {
    validate(frm) {
		// Validate each Item in Child Table and if the Item is_wire is True then ask user to enter the data
        console.log("Validate event fired")
        frm.doc.items.forEach(data => {
            console.log(data);
            let ItemCode = data.item_code;
            frappe.db.get_value('Item', {item_code: ItemCode}, 'is_wire', (r) => {
                if(r.is_wire > 0){
                    if(data.coil_id.length == 0){
                        frappe.throw(__("Please enter Coid ID"));
                    }
                }
            });            
        });
	}
});

Here I am processing each row of Child Table items. But this line if(data.coil_id.length == 0){ gives errorconsole.trace() TypeError: data.coil_id is undefined.

But if you see the JSON file above this field is defined.

Here the surprising thing is that all the custom fields whose fieldtype is either Int or Float are available but all fields of other fieldtype are not available.

On checking the data object I got the following.

{
  "docstatus": 0,
  "doctype": "Purchase Receipt Item",
  "name": "new-purchase-receipt-item-1",
  "__islocal": 1,
  "__unsaved": 1,
  "owner": "Administrator",
  "received_qty": 0,
  "stock_uom": "Kg",
  "retain_sample": 0,
  "margin_type": "",
  "is_free_item": 0,
  "is_fixed_asset": 0,
  "allow_zero_valuation_rate": 0,
  "include_exploded_items": 0,
  "cost_center": "Main - IS",
  "page_break": 0,
  "parent": "new-purchase-receipt-1",
  "parentfield": "items",
  "parenttype": "Purchase Receipt",
  "idx": 1,
  "coil_wt": 0,
  "wire_size": 0,
  "qty": 1,
  "rejected_qty": 0,
  "conversion_factor": 1,
  "received_stock_qty": 0,
  "stock_qty": 1,
  "returned_qty": 0,
  "price_list_rate": 0,
  "base_price_list_rate": 0,
  "margin_rate_or_amount": 0,
  "rate_with_margin": 0,
  "discount_amount": 0,
  "base_rate_with_margin": 0,
  "rate": 99,
  "amount": 99,
  "base_rate": 99,
  "base_amount": 99,
  "stock_uom_rate": 99,
  "net_rate": 99,
  "net_amount": 99,
  "base_net_rate": 99,
  "base_net_amount": 99,
  "valuation_rate": 0,
  "item_tax_amount": 0,
  "rm_supp_cost": 0,
  "landed_cost_voucher_amount": 0,
  "billed_amt": 0,
  "weight_per_unit": 0,
  "total_weight": 0,
  "warehouse": "Raw Material Warehouse - PT",
  "gst_hsn_code": null,
  "is_nil_exempt": 0,
  "is_non_gst": 0,
  "brand": null,
  "item_group": "Raw Material",
  "sample_quantity": 0,
  "asset_category": null,
  "item_code": "Wire",
  "weight_uom": "Kg",
  "item_name": "Wire",
  "description": "Wire",
  "image": "",
  "income_account": "Sales - IS",
  "expense_account": "Cost of Goods Sold - IS",
  "discount_account": null,
  "provisional_expense_account": null,
  "has_serial_no": 0,
  "has_batch_no": 1,
  "batch_no": null,
  "uom": "Kg",
  "min_order_qty": "",
  "discount_percentage": 0,
  "supplier": null,
  "update_stock": 0,
  "delivered_by_supplier": 0,
  "last_purchase_rate": 0,
  "transaction_date": "2022-09-24",
  "against_blanket_order": null,
  "bom_no": null,
  "grant_commission": 0,
  "manufacturer": null,
  "manufacturer_part_no": null,
  "item_tax_rate": "{}",
  "supplier_part_no": null,
  "projected_qty": 0,
  "actual_qty": 0,
  "reserved_qty": 0,
  "has_margin": false,
  "free_item_data": "",
  "child_docname": "new-purchase-receipt-item-1"
}

Is this a bug or there is some scripting problem here?

TIA

Yogi Yang

Hi,

Did you manage to find any solution for this problem?

We are also suck in similar situation. But in our case we are stuck in Work Order.

We have added a few fields in required_items and are trying to validate the data entered in them, but those field are not accessible from custom script.

Here is the list of apps installed.

ERPNext: v14.2.0 (version-14)
Frappe Framework: v14.8.0 (version-14)
Frappe HR: v0.0.1 (develop)
India Compliance: v0.0.1 (develop)
Payments: v0.0.1 (develop)

Does any expert have a workaround for this problem?

Regards,

Sorry I have not been able to find a working solution to this problem.

May be it is a bug in Frappe Framework.