How to click on get items on Custom Script

Hi All,
Just need to know how to make the get items button clicked if the bom no is there. Following is my try. Thanks.

frappe.ui.form.on(‘Stock Entry’, {
refresh(frm) {
if(frm.doc.bom_no){
----------------------------
msgprint(‘Click the Above’);
}
}
})

I tried this and worked. Hope you have a better solution.

$(‘button[data-fieldname=“get_items”]’).click();