- Add a custom HTML field in your target doctype (doctype that will show the table)
- Add the code below as a custom script for the target doctype
frappe.ui.form.on('Target Doctype', 'refresh', function(frm, cdt, cdn){
frappe.call({
'method': 'frappe.client.get_list',
'args': {
'doctype': 'Source DocType',
'columns': ['*']
'filters': [['Source DocType', 'link_reference', '=', frm.doc.name]]
},
'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('html_fieldname', 'options', frappe.render(template, {rows: res.message});
frm.refresh_field('html_fieldname');
}
})
});
Thanks for your effort brother
ReplyDeleteYou saved me a lot of time with this post.
Barak Allah Feek
hello Hafees, what is the Source Doctype ?
ReplyDeleteYour Doctype Name
Delete