Button from cuztomize field on click

Hi,

I have set a button in my field from cuztomize form feature, and i wonder how i could do this :
i have column code , from and to , so when the generate button clicked i want to generate items child table with code+counter as the name .
im looking for example to do this

Thanks

Use:

frappe.ui.form.on("{{ Doctype }}", "{{ button_field_name }}", function(frm) {
    alert("click");
}

For further examples see: https://erpnext.com/user-guide/customize-erpnext/custom-scripts/custom-script-examples

Thanks,
Anand.