HTML field update in child document

I have to update the value of HTML field in a child document, creating an HTML table with Purchase orders:

frappe.ui.form.on(“Purchase Receipt”,
“items_on_form_rendered”: function(frm)
 method: 'frappe.client.get_list',
     doctype: "Purchase Order",
     fields: ["*"]
  callback: function(res)
  	var template = "<table><tbody>{% for (var row in rows) { %}<tr>{% for (var col in rows[row]) { %}<td>rows[row][col]</td>{% } %}</tr>{% } %}</tbody></table>";
  	frm.set_df_property('table_ordini', 'options', frappe.render(template, {rows: res.message}));
  } })  }    });

But the field is not updated.
I try also with a simple content, but it doesnt’ work,

callback: function(res)
var template = “TEST”;
frm.set_df_property(‘table_ordini’, ‘options’, template);

I think that the problem depends on the field that is not in the main document but in a child document, but I don’t know how to use a child field.

Any suggestion?

What is your use case? I am not sure what you are trying to do is good design.

I’m trying to solve the problem of purchase receipt.
When raw material arrive, I have a DN containing:

ORDER A position 1 ITEMCODEA 200KG
ORDER A position 3 ITEMCODEB 500KG
ORDER B position 1 ITEMCODEA 200KG

The user must have the possibility to select a specific order number and position in order to allow system update the received quantity of the correct supply row order.
If i’m not in wrong the two fields that identify the order to update are purchase_order and purchase_order_item in the Purchase Receipt item.
Now the problem is that the field purchase_order_item indeed don’t have the value of row position but an alphanumeric Key (example 9f41d20209) that the user doesnt’ know.

The solution more user friendly in my opinion is to show a table with in each row Po mumber, row number, qty ordered, qty received, and a radio button. Depends on the row selected the fields purchase_order and purchase_order_item has to be filled with correct values.

Is it possible?Or you have another better solution?


1 Like

@rmehta any idea of an alternative solution? Or can you explain to me how to implement what I explained in the previous message?