Dynamic Select Box in Child Table


I am using code to add some options into a select box by passing an item code as a parameter.

Below is my code:
JS Code:

frappe.ui.form.on("Sales Order Custom Parts", "other_options", function(frm, cdt, cdn) {
var d =locals[cdt][cdn];

var item=frappe.get_doc(cdt,cdn);
var d1 =  {   
              "item_code": d.item_code 
    method: "library_management.update_items.alternate_item",
             args: d1,
    callback: function(r) {

frappe.meta.get_docfield('Sales Order Custom Parts', 'alternate_option',cur_frm.doc.name).options 
= r.message;

Python Code:


def alternate_item(item_code):


	for i in frappe.db.sql("""SELECT item_code from `tabItem Alternate` WHERE item_code is not null and item_code!='' and parent=%s""",item_code,as_dict=1):

		j = j+i.item_code+("\n")

	return j

When I select the value of Other Options from No to Yes, the value in the select doesn’t get updated, whereas when I again select it as No and then select Yes, then the value in the select get updated.

Apart from this, I am using the depends on property for Alternate Option Select box, but I do not use that property the value in the select box never get updated.

Any help in this context will be appreciated.

Ruchin Sharma