Formcrafts - a form and survey platform for Salesforce, HubSpot, etc
  1. Templates
    1. All templates illustration
      All templates
    2. Application forms illustration
      Application forms
    3. Calculation forms illustration
      Calculation forms
    4. Lead generation forms illustration
      Lead generation forms
    5. Customer service illustration
      Customer service
    6. Evaluation forms illustration
      Evaluation forms
    7. Survey and feedback illustration
      Survey and feedback
    8. Operations forms illustration
      Operations forms
    9. Payment forms illustration
      Payment forms
    10. Booking and registration illustration
      Booking and registration
    11. Salesforce forms illustration
      Salesforce forms
    12. Other forms illustration
      Other forms
  2. Features
    1. 18 Form Fields illustration
      18 Form Fields
    2. 19 Integrations illustration
      19 Integrations
    3. Conditional Logic illustration
      Conditional Logic
    4. Multi-step Forms illustration
      Multi-step Forms
    5. Calculations illustration
      Calculations
    6. Partial Submissions illustration
      Partial Submissions
    7. Save & Resume illustration
      Save & Resume
    8. Payments illustration
      Payments
    9. Hidden Fields illustration
      Hidden Fields
    10. Dynamic Dropdowns illustration
      Dynamic Dropdowns
    11. Engagement analysis illustration
      Engagement analysis
    12. Multilingual forms illustration
      Multilingual forms
  3. Pricing
  4. Help
  5. Login
  6. Signup
    →
  • Help index
  • Features
    • Conditional logic
    • Prefill forms
    • Multi-step forms
    • Calculations
    • Partial submissions
    • Field references
    • Save and resume
    • Hidden fields
    • Dynamic lookup
    • Workflows
    • Dynamic dropdowns
    • Multilingual forms
    • Privacy mode
    • Success message
    • Form redirect
    • GA/GTM
    • Accept payments
    • Linked forms
    • Disable form
  • Styling
    • Custom CSS
    • Custom fonts
    • Color scheme
    • Form background
  • Analytics
    • Test mode
    • Overview
    • Field analytics
    • Form engagement
  • Workflows
    • Send emails
    • Form redirect
    • Success message
    • Webhooks
    • Create PDF
    • ActiveCampaign
    • Asana
    • Mailchimp
    • Front app
    • Freshdesk
    • Google Sheets
    • Pipedrive
    • Linear
    • Klaviyo
  • Sharing
    • Custom form link
    • Embed on a page (inline)
    • Embed on a page (popup)
    • Embed in emails
    • Embed on WordPress
    • Embed on Shopify
    • Embed on Squarespace
  • Salesforce
    • Overview
    • Create records
    • Update records
    • Related records
    • Dynamic picklists
    • Attach files
    • Create PDFs
    • Form prefill
    • Experience Cloud Embed
    • Record Page Embed
  • HubSpot
    • Overview
    • Create contact form
    • Create lead capture form
    • Create customer survey
    • Prefill HubSpot form
    • Embed on HubSpot page
    • Uninstall
  • Zendesk
    • Create ticket form
    • Create CSAT survey
    • Embed on Help Center
    • Prefill ticket form
  • Admin
    • Users
    • Custom domain
    • Custom email domain
    • Vanity subdomain
    • Subscription
  • Developers
    • Embed Library
    • API keys
    • API v1
    • API v2
  • Others
    • Partner program
    • GDPR compliance
    • Workflow logs
    • White labeling
    • Using JSONPath
    • Form speed
    • Zapier
  • Contact
  1. Help
  2. ›
    Salesforce
  3. ›
    Record Page Embed

Embed a Form on a Salesforce Record Page

On this page
  1. Introduction
  2. Prerequisites
  3. Method 1: Button with Dynamic Actions
    1. Step 1: Get your form’s unique key
    2. Step 2: Create a Button
    3. Step 3: Add the button to the Record Page
  4. Method 2: Visualforce page
    1. Step 1: Create the Visualforce page
    2. Step 2: Add to the record page
  5. Method 3: Lightning Web Component
    1. Step 1: Create the Lightning Web Component
    2. Step 2: Add CSP Trusted Site
    3. Step 3: Add to the record page
  6. Comparison
  7. Notes

Introduction

You can embed a Formcrafts form directly on a Salesforce record page. This is useful for scenarios like allowing users to create a case from a contact record page, or submitting feedback related to an account.

In this guide, we will use the example of embedding a case form on a Contact record page. The form will automatically receive the Contact ID, which can be used to link the case to the contact.

There are three ways to embed a form on a record page:

  1. Button with Dynamic Actions - Add a button on the record page that opens the form with the Contact ID in the URL
  2. Visualforce page - Create a Visualforce page that embeds the form inline on the record page
  3. Lightning Web Component - Create a Lightning component that embeds the form inline on the record page

Prerequisites

Before you begin, set up your form to accept the Contact ID:

  1. Create your form in Formcrafts (e.g., a case submission form)
  2. Add a hidden field to store the Contact ID. Note the field reference (e.g., field1)
  3. Configure your workflow to create a Case in Salesforce, mapping the hidden field to the Contact lookup field

Learn more about using hidden fields and creating records in Salesforce.

Method 1: Button with Dynamic Actions

The simplest approach is to add a button on the record page that opens the form in a new tab, passing the Contact ID as a URL parameter.

Step 1: Get your form’s unique key

Find your form’s unique key under Share → Form key in Formcrafts’ form editor. It will look like:

abcd123

Step 2: Create a Button

  1. In your Salesforce organization, go to Setup → Object Manager → Contact → Buttons, Links, and Actions
  2. Click New Button or Link
  3. Configure the button:
    • Label: Create case (or your preferred name)
    • Name: fc_create_case
    • Display Type: Detail Page Button
    • Behavior: Display in new window
    • Content Source: URL
  4. Enter the following URL:
https://app.formcrafts.com/abcd123?field1={!Contact.Id}

Replace abcd123 with your form’s key, and field1 with your hidden field reference.

  1. Click Save

Step 3: Add the button to the Record Page

  1. Go to Setup → Object Manager → Contact → Lightning Record Pages
  2. Edit the page (or create a new one)
  3. Click on the Highlights Panel at the top of the page
  4. In the right sidebar, find Dynamic Actions and click Add Action
  5. Search for your button (e.g., “Create case”) and add it
  6. Click Save and Activate the page

Now, when viewing a Contact record, users will see a “Create case” button in the highlights panel that opens the form with the Contact ID pre-filled.

Adding a Dynamic Action button to the Highlights Panel

Method 2: Visualforce page

A Visualforce page allows you to embed the form directly on the record page using the Formcrafts embed.js library.

Step 1: Create the Visualforce page

  1. Go to Setup → Visualforce Pages
  2. Click New and enter a name (e.g., “Create case”)
  3. Paste the following code:
<apex:page standardController="Contact">
  <script src="https://app.formcrafts.com/embed.js">script>
  <div
    data-fc-key="abcd123"
    data-fc-prefill-field1="{!Contact.Id}"
    data-fc-seamless="true">
  div>
apex:page>

Replace abcd123 with your form’s key, and field1 with your hidden field reference.

  1. Check Available for Lightning Experience, Experience Builder, and the mobile app
  2. Click Save

Step 2: Add to the record page

  1. Go to Setup → Object Manager → Contact → Lightning Record Pages
  2. Edit the page (or create a new one)
  3. Drag a Visualforce component onto the page
  4. Select your Visualforce page (e.g., “Create case”)
  5. Set the height as needed (e.g., 600 pixels)
  6. Click Save and Activate the page

The form will now appear embedded on the Contact record page with the Contact ID automatically prefilled in the hidden field.

Embedding a Visualforce page on the Contact record page

Method 3: Lightning Web Component

This method is a more advanced approach using a Lightning Web Component to embed the form inline on the record page. This approach is more flexible since it allows you to specify the form key in the Lightning App Builder, and has auto-adjusting height.

Step 1: Create the Lightning Web Component

Create a new Lightning Web Component in your Salesforce org (via Developer Console or VS Code with Salesforce CLI). Name the component formcraftsForm.

formcraftsForm.html:

<template>
  <div lwc:dom="manual" class="formcrafts-container">div>
  <template if:true={isLoading}>
    <lightning-spinner
      alternative-text="Loading form..."
      size="medium">lightning-spinner>
  template>
  <template if:true={error}>
    <div class="slds-text-color_error">{error}div>
  template>
template>

formcraftsForm.js:

import { LightningElement, api, track } from 'lwc';

export default class FormcraftsForm extends LightningElement {
    @api formKey = '';
    @api prefillField = '';
    @api recordId;

    @track isLoading = true;
    @track error = null;

    formInstance = null;
    scriptLoaded = false;

    connectedCallback() {
        this.loadFormcraftsScript();
    }

    disconnectedCallback() {
        if (this.formInstance) {
            this.formInstance.destroy();
        }
    }

    loadFormcraftsScript() {
        if (window.formcrafts_embed) {
            this.scriptLoaded = true;
            this.initializeForm();
            return;
        }

        const script = document.createElement('script');
        script.src = 'https://app.formcrafts.com/embed.base.js';
        script.onload = () => {
            this.scriptLoaded = true;
            this.initializeForm();
        };
        script.onerror = () => {
            this.isLoading = false;
            this.error = 'Failed to load Formcrafts embed script.';
        };
        document.head.appendChild(script);
    }

    initializeForm() {
        if (!this.formKey) {
            this.isLoading = false;
            this.error = 'Form key is required. Please configure the component.';
            return;
        }

        const container = this.template.querySelector('.formcrafts-container');
        if (!container || !window.formcrafts_embed) {
            return;
        }

        try {
            const config = {
                form: this.formKey,
                target: container,
                seamless: true,
                width: null,
                redirectWithin: true
            };

            if (this.prefillField && this.recordId) {
                config.values = {
                    [this.prefillField]: this.recordId
                };
            }

            this.formInstance = window.formcrafts_embed.createInlineForm(config);

            this.formInstance.on('load', () => {
                this.isLoading = false;
            });
        } catch (err) {
            this.isLoading = false;
            this.error = 'Failed to initialize form: ' + err.message;
        }
    }
}

formcraftsForm.js-meta.xml:

xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  <apiVersion>59.0apiVersion>
  <isExposed>trueisExposed>
  <targets>
    <target>lightning__AppPagetarget>
    <target>lightning__RecordPagetarget>
    <target>lightning__HomePagetarget>
    <target>lightning__Tabtarget>
  targets>
  <targetConfigs>
    <targetConfig targets="lightning__AppPage,lightning__RecordPage,lightning__HomePage">  
      <property name="formKey" type="String" label="Form Key"
        description="Your Formcrafts form key (e.g., abcd123)" required="true"/>
      <property name="prefillField" type="String" label="Prefill Field"
        description="The ID of the form field to prefill with the record ID (e.g., field1)"/>
    targetConfig>
  targetConfigs>
LightningComponentBundle>

Step 2: Add CSP Trusted Site

  1. Go to Setup → CSP Trusted Sites
  2. Click New Trusted Site
  3. Enter a name (e.g., “Formcrafts”) and the URL https://app.formcrafts.com
  4. Check Allow site for scripts
  5. Click Save

Step 3: Add to the record page

  1. Go to Setup → Object Manager → Contact → Lightning Record Pages
  2. Edit the page (or create a new one)
  3. Find your component (e.g., “formcraftsForm”) in the custom components section
  4. Drag it onto the page
  5. Configure the component properties:
    • Form Key: Enter your Formcrafts form key (e.g., abcd123)
    • Prefill Field: Enter the field reference to prefill with the Record ID (e.g., field1)
  6. Click Save and Activate the page

The Record ID is automatically passed to the form when placed on a Record Page. This works with any Salesforce object (Contact, Account, Lead, etc.).

Embedding a Lightning Web Component on the Contact record page

Comparison

Feature Button Visualforce Lightning Component
Setup complexity Low Medium High
Embedded on page No Yes Yes
Real-time updates No Yes Yes
Custom styling Limited Yes Yes
Mobile support Yes Yes Yes

Notes

  • The Contact ID passed to the form can be used with Salesforce lookups to fetch additional contact data and prefill other fields
  • You can adapt these methods for other Salesforce objects (Account, Lead, Opportunity, etc.) by changing the object references
Minimal, fast, and powerful. Try now.
Formcrafts - a form and survey platform for Salesforce, HubSpot, etc

Subtle Web Inc,
225 Railway St E,
T4C 2C3, Cochrane AB

Salesforce AppExchange partner logo HubSpot app partner logo
Templates
Application formsLead generation formsSurvey & feedback formsEvaluation formsSupport request formsBooking & registrationContact forms
Comparisons
vs AllFormAssemblyTypeformJotformWufooSurveyMonkey
Features
Conditional logicSalesforce formsHubSpot formsZendesk ticket formsEmail formsIntegrationsForm fields
Resources
Help centerBlogDeveloper APIGDPRStatusReport abuseContact us
Company
About usNonprofitCase studiesSecurityTerms and privacy