Adding Record Action Buttons - Magic Merge Knowledge Base

Adding Record Action Buttons

Record action buttons allow users to generate documents directly from Salesforce record pages with a single click. This guide shows you how to add Magic Merge buttons to your page layouts.

Why Add Action Buttons

Action buttons provide quick access to document generation:

  • Generate invoices directly from Opportunity records
  • Create contracts from Account pages
  • Print shipping labels from Order records
  • Streamline repetitive document workflows

Adding Buttons to Page Layouts

Step 1: Open Page Layout Editor

  1. Navigate to Setup in Salesforce
  2. Search for Object Manager
  3. Select the object you want to add a button to (e.g., Account, Opportunity)
  4. Click Page Layouts
  5. Select the layout you want to edit

Step 2: Add the Magic Merge Button

  1. In the page layout editor, find Buttons in the palette
  2. Locate the Magic Merge custom buttons
  3. Drag the desired button to the Custom Buttons section
  4. Click Save

Note: Magic Merge buttons must be created before they can be added to page layouts. See the "Creating Custom Buttons" section below.

Creating Custom Buttons

To create a button that merges a specific template:

Step 1: Create the Button

  1. Go to Setup > Object Manager
  2. Select your object
  3. Click Buttons, Links, and Actions
  4. Click New Button or Link

Step 2: Configure Button Properties

  • Label: Enter the button text (e.g., "Generate Invoice")
  • Name: API name for the button
  • Display Type: Select "Detail Page Button"
  • Behavior: Choose "Execute JavaScript"
  • Content Source: Select "OnClick JavaScript"

Step 3: Add the JavaScript Code

Use the Magic Merge JavaScript API to trigger the merge:

{!REQUIRESCRIPT("/soap/ajax/48.0/connection.js")}
MagicMerge.generateDocument('{!Template.Id}', '{!Account.Id}');

Tip: Replace Template.Id with your actual template ID and adjust the object reference (Account.Id) based on your object type.

Button Types

Single Record Buttons

Generate a document for the current record being viewed. Best for invoices, contracts, and individual reports.

Related List Buttons

Bulk generate documents for multiple selected records from a related list. Useful for batch processing orders, statements, or certificates.

List View Buttons

Process multiple records selected from a list view. Ideal for mass mailings or bulk document generation.

Best Practices

  • Descriptive Labels - Use clear button names like "Email Quote" instead of generic "Merge"
  • Consistent Placement - Add buttons in the same location across similar objects
  • Test in Sandbox - Always test new buttons in a non-production environment first
  • User Training - Document button functionality for your team

Common Questions

Can I control which users see the button?

Yes. Use page layout assignments to show different layouts (with different buttons) to different user profiles.

How many buttons can I add to a page layout?

Salesforce allows multiple custom buttons per layout. However, for better user experience, limit buttons to the most commonly used merge operations.

Can buttons be added to Lightning Record Pages?

Yes. In Lightning App Builder, add the "Magic Merge" component to your record page and configure it to display specific merge buttons.

Need Help? Contact support if you need assistance configuring buttons for complex merge scenarios or custom object relationships.