Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    • How to Handle Bulkification in Apex with Real-World Use Cases
    • How to Confidently Manage Transactions in Salesforce Apex
    • Building a Dynamic Tree Grid in Lightning Web Component
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Saturday, August 2
    • Home
    • Salesforce Platform
      • Architecture
      • Apex
      • Lightning Web Components
      • Integration
      • Flows & Automation
      • Best Practices
      • Questions
      • News
      • Books Testimonial
    • Industries
      • Artificial Intelligence
    • Hire Me
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Downloads
      • Salesforce Release Notes
      • Apex Coding Guidelines
    • About Us
      • Privacy Policy
    • Contact Us
    SalesforceCodex
    Home»Salesforce»Apex»Dynamic Record Page Creation using FieldSet

    Dynamic Record Page Creation using FieldSet

    Dhanik Lal SahniBy Dhanik Lal SahniNovember 18, 2021Updated:November 7, 20232 Comments2 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Dynamic Record Page Creation using FieldSet
    Share
    Facebook Twitter LinkedIn Pinterest Email

    We usually get the requirement to develop a lightning page for creating records in the Salesforce object. We have to create different components for creating different kinds of object records. Instead of creating multiple components, we can utilize FieldSet to create dynamic pages. This post will explain dynamic record page creation using a fieldset.

    Fieldset is group of fields and used to add, remove and reorder fields. FieldSets are used to style forms and display those logical associations between fields. FieldSets are used to display fields.

    Let us see how we can create the dynamic page using Fieldset. The below steps are required to create a dynamic page

    1. Create an apex class to get fields from the fieldset
    2. Create a generic lighting component
    3. Test Component

    1. Create an apex class to get fields from the fieldset

    Let us create an apex class that will get field details based on the given field set and object. We will use Schema.DescribeSObjectResult, Schema.getGlobalDescribe and Schema.FieldSet to get field details. These will be used for describing sObject.

    After getting object descriptions from the above-mentioned classes, we will prepare a list of field information. This list will be used in LWC component to create the page.

    Code for getting field detail for a given object and fieldset

    2. Create a generic lighting component

    Create a re-usable LWC component that will use the above apex class and lightning-record-edit-form to generate the layout. By default, it will display controls in 1 control per row, if you want to show 2 or 3 columns per row then use a lightning design system to generate multiple columns. slds-col slds-size_1-of-2 style will convert rows into 2 columns layout.

    We need to get the object name, field set, or record id to display the page. So create public properties for this information.

    Public properties that are required are

    1. Record ID
    2. Object Name
    3. FieldSet Name

    3. Test Component

    To test the component, create a field set in 2 different objects. Add the above-created component on the record page or home page in Lightning.

    FieldSet in Account Page:

    Configure Component:

    Test Video:

    References:

    About Field Sets

    Other similar posts:

    Adding table row dynamically in Lightning Web Component

    apex dynamic page fieldset lightning Lightning web component lightning-record-edit-form record-edit-form
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAvoid Batch Apex and Use Queueable Class
    Next Article Optimizing Salesforce Apex Code
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI

    July 28, 2025
    By Dhanik Lal Sahni7 Mins Read

    Top Mistakes Developers Make in Salesforce Apex Triggers

    July 25, 2025
    By Dhanik Lal Sahni14 Mins Read

    The Ultimate Guide to Apex Order of Execution for Developers

    July 20, 2025
    View 2 Comments

    2 Comments

    1. Ankit on November 4, 2023 11:35 pm

      will it work with Lookup fields too?

      Reply
      • Dhanik Lal Sahni on November 7, 2023 7:55 am

        Yes Ankit, It will work as we are using lightning-record-edit-form.

        Thank You,
        Dhanik

        Reply
    Leave A Reply Cancel Reply

    Ranked #1 Salesforce Developer Blog by SalesforceBen.com
    SFBenTopDeveloper
    Ranked #4 Salesforce Developer Blog by ApexHours.com
    ApexHoursTopDevelopers
    Categories
    Archives
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    MailChimp

    Expert Salesforce Developer and Architect
    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • Top 10 Salesforce CRM Trends to Watch in 2025 July 18, 2025
    • Discover the Top 10 Salesforce AppExchange Apps to Boost Productivity July 10, 2025
    • Top 20 Salesforce Data Cloud Interview Questions & Answers for Admins June 5, 2025
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    Archives
    Categories
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.