Hi i have created a series

frappe.ui.form.on('Sales Invoice', {
    custom_sales_type: function(frm) {
        frm.trigger('update_naming_series');
    },
    update_naming_series: function(frm) {
        switch (frm.doc.custom_sales_type) {
            case "B2B PRODUCT INDIA":
                frm.set_value('naming_series', "SI24B25/I./");
                break;
            case "B2C PRODUCT INDIA":
                frm.set_value('naming_series', "SI24C25/I./");
                break;
            case "B2B CONSUMABLES INDIA":
                frm.set_value('naming_series', "SI24B25/C./");
                break;
            case "B2C CONSUMABLES INDIA":
                frm.set_value('naming_series', "SI24C25/C./");
                break;
            case "B2B SPARES INDIA":
                frm.set_value('naming_series', "SI24B25/S./");
                break;
            case "B2C SPARES INDIA":
                frm.set_value('naming_series', "SI24C25/S./");
                break;
            case "B2B AMC INDIA":
                frm.set_value('naming_series', "SI24B25/A./");
                break;
            case "B2C AMC INDIA":
                frm.set_value('naming_series', "SI24C25/A./");
                break;
            case "SALES INTERNATIONAL":
                frm.set_value('naming_series', "SI24I25/F./");
                break;
            default:
                frm.set_value('naming_series', "");
        }
        frm.refresh_field('custom_sales_type');
    }
});

Here this is not working when i import or when i use get items from on sales invoice it only work when i manualy changes the sales type

Please check the example.

You i used refresh function in that case it is working for for bot excel import and get items from but it is not working for manually change after saving it is not changing iin manual case

Because you defined the wrong way! again check the reference. My reference also worked, in manual case.

refresh: function(frm) {
frm.trigger(‘update_naming_series’);
},
custom_sales_type: function(frm) {
frm.trigger(‘update_naming_series’);
},
update_naming_series: function(frm) {
changed like this and now i is working

No need.

You can apply it.

refresh: function(frm) {
    frm.trigger('custom_sales_type');
},
custom_sales_type: function(frm) {
    // add your series code
},