Scripting custom button in a table doctype

I created a custom field button in a Maintenance Visit Purpose table and I’m trying run something when I click it.
Tried:

frappe.ui.form.on("Maintenance Visit Purpose", "orcamento", function(frm){
	cur_frm.cscript.orcamento = function(){console.log("works!");
})

frappe.ui.form.on("Maintenance Visit Purpose", "orcamento", function(frm){
	console.log("works!");
})

Some help, please?

Try with:

frappe.ui.form.on("Maintenance Visit Purpose", "orcamento", function(frm){
     cur_frm.cscript["orcamento"] = function(doc, dt, name){
  		alert('works')
	}
});

What’s ev?
function(ev)?

It’s the form, doesn’t matter the name you assign to the variable.
I have edit my answer.

That’s worked!
Thank you very much @froldan

You’re welcome
I realized that my answer is the same that your first approach, you just have a syntax error, missing “}” after console.log(“works!”).