ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

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


#1
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)


Filter for select field type
#2

In your callback

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

Set Value in select type field
#3

great! thank you soo much :smiley:


#4

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

screenshot
after save
Capture11

after refresh

Capture12


#5

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!!