ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Is it Possible to Dynamically change Option(s) on a 'Select' field?

frappe.ui.form.on("Senior High Spreadsheets", "semester", function(frm) {
	//console.log('hello')

	 frappe.call({
        method: "wela.registration.doctype.senior_high_spreadsheets.senior_high_spreadsheets.get_subjects",
        args: {
            "semester": frm.doc.semester,
			"strand": frm.doc.strand
        },
        callback: function (r) {
        	console.log('HELLO soy');
        	console.log(r.message["result"]);
			//cur_frm.set_cur_list("grading_subject",r.message["result"]);
			var x = r.message["result"]
        }
    });
})

my x is a list, and I want x to be the values in my "grading_subject field

my Doctype

the Form, in Grading Subject I want x to be the option(s)

In your callback

frm.set_df_property('grading_subject', 'options', ['option a', 'option b']);
frm.refresh_field('grading_subject');
8 Likes

great! thank you soo much :smiley:

Value is saving in database but when refresh the document value not shown in field?

screenshot
after save
Capture11

after refresh

Capture12

It is working…but by doing so CSS style of drop down has changed…

Its seems like normal drop down…

how to change its style…?

Any help?

Thanks!!

Hello,
Can you please share the get_subjects method from the .py file.
Thanks