How to auto-select option depended on previous field?

Hi @youssef ,

thankyou for the code, I use it as a reference to my case.

Below is the code as reference to other as well :

frappe.ui.form.on("Sales Order", "refresh", function(frm) {
  
  if(frm.doc.order_type == "Samples")
  {
    set_field_options("naming_series", ["SDR-.YYYY.-"]);
    cur_frm.set_value("naming_series", "SDR-.YYYY.-");        
  }
 
  else if(frm.doc.order_type == "Sales")
  {
    set_field_options("naming_series", ["SO-."]);
    cur_frm.set_value("naming_series", "SO-.");        
  }
  
  });

this is to handle a scenario when the record is loaded for the first time render

reference : What event cur_frm.cscript have?

thankyou once again.