Get HSN code of first item from items table in Sales Invoice

hello everyone,

quite new to erpnext and scripting too .I am trying to fetch only first item’s HSN code from items table(Sales invoice Item) of sales invoice,into custom field of Sales Invoice doc.
source field is “gst_hsn_code”(Sales Invocie Item) .
my custom target field name is “gst_hsn_code”(Sales Invoice) .
I am referring following code please suggest the changes in this script.

 frappe.ui.form.on("Sales Invoice","items", function(frm, cdt, cdn) {
  frappe.call({
    method: "frappe.client.get_list",
    args: {
           doctype: "Sales Invoice Item",
        filters:{
              "item_code" : frm.doc.items
        },


               fields: ["gst_hsn_code"]
    },
  
    callback: function(r) {
            var items = [];
            frm.clear_table("gst_hsn_code");
            for(var i=0; i< r.message.length; i++) {
                var d = frm.add_child("gst_hsn_code");
	for (var key in r.message[i]) {
		    if (r.message[i].hasOwnProperty(key)) {           
		frappe.model.set_value(d.doctype, d.name, key, r.message[i][key]);
		    }
	}

                if(!d.qty) d.qty = 1;
            }
            frm.refresh_field("items");
        }

})

})

thanks in advance
sooraj