Open Customer doctype with Customer ID

This is super basic, however I haven’t been able to find anything to help me in the docs :frowning:

I’m working with a client script and I want my button to go to the customer form and open the Customer ID I pass it. I’m currently using a URL. Is there a frappe.xxx function that I could use instead of the below?

frappe.ui.form.on('Lease Agreement', {
	refresh(frm) {
		
		
		frm.add_custom_button(__("Return to Customer"), function() {

          let cust = frm.doc.customer
         
          window.location.href = "http://localhost:8000/app/customer/" + cust;

         
			});
		
	}
})

Hi @Shaun,

Please apply it.

frappe.ui.form.on('Lease Agreement', {
	refresh: function(frm) {
	    frm.add_custom_button(__("Return to Customer"), function() {
	        let cust = frm.doc.customer;
	        window.location.href = "/app/customer/" + cust;
	    });
	}
});

Then reload and check it.

Thank You!

1 Like

Thanks for the suggestion @NCP. This solution still reloads the whole page though. Is there not another way?

Try this inside your button action:

frappe.set_route("Form", "Customer", frm.doc.customer);
1 Like

Perfect, thanks so much.