Hello I’am new at erpnext/frappe
How can I return the fields of doctype selected and put them into select options custom script
Hello I’am new at erpnext/frappe
How can I return the fields of doctype selected and put them into select options custom script
dear Hela_Guesmi,
can you elaborate your question?
Thank you for your reply I resolve the problem
@Hela_Guesmi great that you resolved it, generally you should post your solution for the community to benefit.
frappe.ui.form.on('Doctype Name', {
doc_type: function(cur_frm, cdt, cdn) {
let row = frappe.get_doc(cdt, cdn);
if (!row.doc_type) {
frappe.msgprint(__("Select Document Type."));
return;
}
frappe.model.with_doctype(row.doc_type, function() {
var options = $.map(frappe.get_meta(row.doc_type).fields,
function(d) {
if(d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype)===-1) {
return d.fieldname;
}
return null;
}
);
console.log('test options select field' + options);
frappe.meta.get_docfield("Doctype Name", "fields", cur_frm.doc.name).options = [""].concat(options);
frappe.model.set_value(cdt, cdn,"fields", options);
cur_frm.refresh_field("fields");
});