Hi,
I want to load option of select field dynamically so id did this
frappe.ui.form.on('Program', 'onload', function(frm){
var options = [];
// frappe.meta.get_docfield('Program', 'program_abbreviation').options = options;
// console.log(options);
frappe.call({
method: 'erpnext.schools.doctype.program.program.get_name_id_of_student',
args: {
'nameofdoctype': 'Department', // DocType that is the source of the options
//'fields': ['name', 'department'] // Fields that will provide the options (one for value, another for label, or use a single one for both)
//'filters': [['NFe Parameters', 'group', '=', 'IPI CST']] // filter conditions while fetching a list of values
},
callback: function(res){ // receive the response from the server
(res.message || []).forEach(function(row){ // start a loop over all options in the response, or in a empty list;
// console.log(row.key);
// console.log(row.value);
options.push({'value': 'x', 'label': 'x'}) // makes a option entry 'value' and 'label'
});
console.log(options);
frm.fields_dict.program_abbreviation.options = options;
frappe.meta.get_docfield('Program', 'program_abbreviation').options = options;
// define de options for the field in this case (ipi_cst)
}
});
console.log(options);
});
but i get nothing in select field
and if i change above code to
frappe.ui.form.on(‘Program’, ‘onload’, function(frm){
var options = [‘x’,‘y’,‘z’];
frappe.meta.get_docfield(‘Program’, ‘program_abbreviation’).options = options;
// console.log(options);
frappe.call({
method: ‘erpnext.schools.doctype.program.program.get_name_id_of_student’,
args: {
‘nameofdoctype’: ‘Department’, // DocType that is the source of the options
//‘fields’: [‘name’, ‘department’] // Fields that will provide the options (one for value, another for label, or use a single one for both)
//‘filters’: [[‘NFe Parameters’, ‘group’, ‘=’, ‘IPI CST’]] // filter conditions while fetching a list of values
},
callback: function(res){ // receive the response from the server
(res.message || []).forEach(function(row){ // start a loop over all options in the response, or in a empty list;
// console.log(row.key);
// console.log(row.value);
options.push({‘value’: ‘x’, ‘label’: ‘x’}) // makes a option entry ‘value’ and ‘label’
});
console.log(options);
frm.fields_dict.program_abbreviation.options = options;
frappe.meta.get_docfield(‘Program’, ‘program_abbreviation’).options = options;
// define de options for the field in this case (ipi_cst)
}
});
console.log(options);
});
select box has value x,y,z
please help me to do that