How to trigger custom script after importing data

I have some scripts running on Item doctype.
Everything works in a perfect way.

There is only one issue when I import data.
after_save event does not do anything when I import Excel data.

How can i trigger the code below when I import new items using Data Import?

frappe.ui.form.on("Item", {
    after_save: function(frm) {
        if(frm.doc.item_group == "Product"){
            var custom_serial_no = frm.doc.item_code;
            custom_serial_no += ".###";
            frm.set_value('serial_no_series', custom_serial_no);
        }
    }
});

anyone?

Did you try validate?
It should get triggered after import

Yes, I have tried that but did not make any difference. Unless I open the item and manually click save, nothing happens.

From what I know, it is difficult to trigger Custom Scripts on Import, since it is not a Front End event

Thank you for your reply @Manan_Shah

It actually worked when i used timeline_refresh instead of validate or after_save

1 Like

Is there a reason behind this? cant see controller methods called timeline_refresh, referenced on the docs.