Customize Form - Actions Table

The actions table in the Customize Form Doctype allows users to define custom actions or buttons for the selected Doctype. Each row in the actions table represents a specific action and includes fields that determine its behavior and functionality. Below is a breakdown of each field in the actions table and its usage:


1. label

  • Description: The text displayed on the action button.
  • Use: Describes the purpose of the action. For example, "Approve," "Reject," or "Send Email."

2. action_type

  • Description: Specifies the type of action to be performed.
  • Use:
    • Common options include:
      • Server Script: Executes a server-side script.
      • Client Script: Runs a client-side script.
      • Route: Redirects to another page or view.
      • Link: Opens a specific record or external link.

    • Example: Set action_type to "Server Script" to trigger backend logic when the button is clicked.

3. action

  • Description: Defines the action to be performed, such as a JavaScript function or server method.
  • Use:
    • If action_type is "Server Script," specify the method to call (e.g., frappe.call).
    • If action_type is "Route," specify the route to navigate to (e.g., /app/sales-invoice).
    • If action_type is "Client Script," include the JavaScript code to execute.
    • Example:
      function() {
        frappe.msgprint("Action performed!");
      }
      


4. group

  • Description: Categorizes the action under a specific group.
  • Use: Organize actions into logical groups in the UI. For example:
    • Group related actions such as "Send Email" and "Print Invoice" under "Communication."


5. hidden

  • Description: Indicates whether the action should be hidden from the user interface.
  • Use: Hide actions that are only intended for specific users or scenarios, or when actions are temporarily disabled.

6. idx

  • Description: Sequence number of the action in the list.
  • Use: Determines the display order of actions in the UI.

Examples of Usage:

  1. Approve Button:

    • label: Approve
    • action_type: Server Script
    • action: custom_app.approve_document
    • Use: Adds an "Approve" button that calls a server-side function to approve the document.
  2. Redirect to Another Doctype:

    • label: View Related Invoices
    • action_type: Route
    • action: /app/sales-invoice
    • Use: Adds a button that redirects users to the Sales Invoice list view.
  3. Trigger Client-Side Logic:

    • label: Show Alert
    • action_type: Client Script
    • action:
      function() {
        frappe.msgprint("This is a custom alert.");
      }
      
    • Use: Adds a button that displays a custom alert when clicked.
  4. Hidden Action for Admin Use:

    • label: Reset Settings
    • action_type: Server Script
    • action: custom_app.reset_settings
    • hidden: Checked
    • Use: Provides a backend utility accessible only to administrators.
  5. Grouped Actions:

    • label: Email Customer
    • action_type: Server Script
    • action: custom_app.send_email
    • group: Communication
    • Use: Organize all communication-related actions under a single group.

By using the actions table, you can add powerful custom buttons to a Doctype, enhancing its functionality and streamlining workflows. These actions can be tailored to meet specific business requirements and improve the user experience.

Discard
Save
Was this article helpful?

On this page

Review Changes ← Back to Content
Message Status Space Raised By Last update on