Queries regarding Client Side Scripting for a Custom Doctype

I have a custom (single) doctype with a Link field to Item doctype. Now I only want to show items which have variants in this Field can some one please let me know how should I go about it with js file in the folder of the this custom doctype.

I know it seems like a very easy question but I have never done any client side (js) scripting for my custom doctypes.


frappe.ui.form.on("Custom Doctype", {
  onload: function(frm) { 
    cur_frm.set_query("item", {"filters": {"has_variants": 1}});