How to get hold of newly selected Delivery Note Item?

When I use this method:

frappe.ui.form.on("Delivery Note Item", "item_code", function(frm, cdt, cdn){
    item = locals[cdt][cdn]

    msgprint(item.item_code);
    msgprint(item.price_list_rate);
    cur_frm.refresh_fields();
    cur_frm.cscript.recalculate();
    msgprint(item.price_list_rate);
});

what I get is the previously selected Delivery Note Item. So this is like before update event.

How can I get the newly selected Delivery Note Item? Suppose I am changing my selection from Item A to Item B, I would like to get Item B, not Item A. The code above gives me Item A. Is there anything like after update event?

Sorry, this question was posted before inside the topic: Populate Custom Field in Item to Delivery Note Item. But I haven’t got an answer. So I am posting it as a new topic.

-nanto

@nanto_himawan tried your script. It shows me the value after update. Check if you have some other errors in your JS console.

Hi @rmehta,

Thank you for trying, but I still can’t figure out any error. Which JSConsole are you talking about? I am using Firefox. Which browser did you use? There’s no other code in my custom script, except for the code I put in my posting. How would it be possible for me to get any error that you don’t get?

-nanto