How to set value for html field in child table

How to set value for html field in child table

1 Like

@revant_one your case is for fields in cur_frm

@Hafees_Kazhunkil it is a bit complicated but

frappe.ui.form.on("My Subtable", "form_render", function(frm, cdt, cdn){
    var d = locals[cdt][cdn],
    wrapper = frm.fields_dict[d.parentfield].grid.grid_rows_by_docname[cdn].fields_dict["html_field"].wrapper;

Thank you @max_morais_dmm

It worked for me after making small change in your code

var d = locals[cdt][cdn]
wrapper = frm.fields_dict[d.parentfield].grid.grid_rows_by_docname[cdn].grid_form.fields_dict['html'].wrapper

grid_form form was missing


Thanks a lot for all of you: @max_morais_dmm, @Hafees_Kazhunkil and @revant_one
It is a very helpful post.
But I need to add one more point which is related to my experience which is based on erpnext version 11 and frappe version 11, it did not work with me using fields_dict["barcode_image"] but it worked as following:
$(frm.fields_dict[item_barcode.parentfield].grid.grid_rows_by_docname[cdn].grid_form.fields_dict.barcode_image.wrapper).html('<svg id="code1 28"></svg>');

Note: barcode_image is configured as image, but the same thing in case of using html field.

So instead of fields_dict['barcode_image'], it only worked if I used fields_dict.barcode_image.