Dynamic Select Box in Child Table

Hi,

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 
         };   
frappe.call({
    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;
refresh_field(alternate_option);
 			}
    });
});

Python Code:

@frappe.whitelist(allow_guest=True)

def alternate_item(item_code):

	j=""

	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.

Regards
Ruchin Sharma