---
title: "Adding Custom Button To Form"
space: "Framework"
url: "https://docs.frappe.io/framework/user/en/guides/app-development/adding-custom-button-to-form"
updated: "2026-02-17"
---


To create a custom button on your form, you need to edit the javascript file associated to your doctype. For example, If you want to add a custom button to User form then you must edit `user.js`.

In this file, you need to write a new method `add_custom_button` which should add a button to your form.

#### Function Signature for `add_custom_button(...)`
 ```js
 frm.add_custom_button(__(buttonName), function() {
 // perform desired action such as routing to new form or fetching etc.
 }, __(groupName));
 ```

#### Example-1: Adding a button to User form
We should edit `frappe/core/doctype/user/user.js`

 ```js
 frappe.ui.form.on('User', {
    refresh: function(frm) {
        frm.add_custom_button(__('Get User Email Address'), function() {
            frappe.msgprint(frm.doc.email);
        }, __("Utilities"));
    }
 });
 ```

You should be seeing a button on user form as shown below,

![Custom Button](/files/add_custom_button.png)

