Thursday, June 11, 2026

LWC: Salesforce Field Set Renderer

LWC: Salesforce Field Set Renderer

Dynamically render Salesforce Field Sets in Lightning Web Components without hardcoding field names.

📖 Overview

Field Set Renderer is a reusable Salesforce Lightning Web Component that reads a named Field Set through Apex and dynamically renders fields at runtime. This approach eliminates hardcoded field references and allows administrators to control the UI simply by updating the Field Set configuration.

✨ Features

Feature Description
Zero Hardcoded Fields Field list is driven entirely by Field Set metadata.
View & Edit Modes Supports both lightning-record-view-form and lightning-record-edit-form.
FLS Aware Automatically respects field-level security permissions.
Required Validation Supports Field Set required and database required fields.
Configurable Layout Supports one-column and two-column layouts.
Lightning App Builder Ready Fully configurable through App Builder properties.

🏗 Architecture

FieldSetService.cls
        │
        ▼
Reads FieldSet Metadata
        │
        ▼
fieldSetRenderer (Reusable LWC)
        │
        ▼
View Mode / Edit Mode
        │
        ▼
Dynamic Salesforce Record Forms

📁 Project Structure

salesforce-fieldset-renderer
│
├── force-app
│   └── main
│       └── default
│           ├── classes
│           │   ├── FieldSetService.cls
│           │   └── FieldSetServiceTest.cls
│           │
│           └── lwc
│               ├── fieldSetRenderer
│               └── fieldSetRendererDemo
│
├── README.md
└── sfdx-project.json

⚙️ Apex Service Example

public with sharing class FieldSetService {

    public class FieldSetField {
        @AuraEnabled public String label;
        @AuraEnabled public String apiName;
        @AuraEnabled public String fieldType;
        @AuraEnabled public Boolean required;
        @AuraEnabled public Boolean editable;
    }

    @AuraEnabled(cacheable=true)
    public static List<FieldSetField> getFieldSetFields(
        String objectApiName,
        String fieldSetName
    ) {
        // Reads FieldSet metadata dynamically
    }
}

💻 LWC Usage Example

<c-field-set-renderer
    record-id={recordId}
    object-api-name="Contact"
    field-set-name="Contact_Overview"
    mode="view"
    columns="2"
    onrecordsave={handleSave}
    oncancel={handleCancel}>
</c-field-set-renderer>

🎯 Public API

Property Description
recordId Salesforce record Id.
objectApiName API name of SObject.
fieldSetName Developer name of Field Set.
mode View or Edit mode.
columns 1 or 2 column layout.

🚀 Deployment

sf org login web -a myOrg

sf project deploy start \
--source-dir force-app \
-o myOrg

🔒 Security & Permissions

  • Uses with sharing to respect record-level security.
  • Respects Field-Level Security (FLS).
  • Editable fields are automatically determined using Salesforce permissions.
  • Supports required field enforcement.

✅ Benefits

  • Reduces maintenance effort.
  • Admin-controlled UI configuration.
  • Reusable across multiple Salesforce objects.
  • Improves scalability and flexibility.
  • Ideal for dynamic forms and metadata-driven applications.

📌 Conclusion

Salesforce Field Set Renderer is a powerful reusable Lightning Web Component that dynamically renders fields based on Field Set metadata. By eliminating hardcoded field references, it enables administrators to manage layouts without code changes while maintaining security, flexibility, and scalability.

Wednesday, June 10, 2026

LWC: Custom Object Creator

LWC: Custom Object Creator

LWC: Custom Object Creator

This Salesforce project demonstrates how to create custom objects dynamically using Lightning Web Components (LWC) and Apex. It helps developers understand metadata-driven development in Salesforce.


LWC Custom Object Creator

✨ Key Features

  • Create Custom Object using LWC UI
  • Apex integration for metadata operations
  • Reusable architecture
  • Salesforce best practices implementation

📁 Project Structure


lwc-custom-object-creator/
│
├── force-app/
│   └── main/
│       └── default/
│           ├── classes/
│           │   └── CustomObjectController.cls
│           └── lwc/
│               └── customObjectCreator/
│
├── README.md
└── sfdx-project.json
    

⚙️ Apex Controller


public with sharing class CustomObjectController {

    @AuraEnabled
    public static String createCustomObject(String objectName) {
        // Logic to create custom object dynamically
        // Metadata API / Tooling API usage required
        return 'Custom Object Created: ' + objectName;
    }
}
    

💻 LWC Component Example

HTML


<template>
    <lightning-card title="Custom Object Creator">
        <lightning-input label="Object Name" onchange={handleChange}></lightning-input>
        <lightning-button label="Create Object" onclick={handleCreate}></lightning-button>
    </lightning-card>
</template>
    

JavaScript


import { LightningElement } from 'lwc';
import createCustomObject from '@salesforce/apex/CustomObjectController.createCustomObject';

export default class CustomObjectCreator extends LightningElement {

    objectName;

    handleChange(event) {
        this.objectName = event.target.value;
    }

    handleCreate() {
        createCustomObject({ objectName: this.objectName })
            .then(result => {
                console.log(result);
            })
            .catch(error => {
                console.error(error);
            });
    }
}
    


📌 Conclusion

This project demonstrates how Salesforce developers can use LWC and Apex to build metadata-driven solutions. It is useful for learning dynamic object creation, platform APIs, and scalable architecture patterns.

LWC: Export & Import Multiple Custom Setting Records

LWC: Export & Import Multiple Custom Setting Records

LWC: Export & Import Multiple Custom Setting Records

This project demonstrates how to export and import multiple Custom Setting records in Salesforce using Lightning Web Components (LWC) and Apex integration.


✨ Features

  • Export Custom Setting records to CSV
  • Import records using file upload
  • Apex-based backend processing
  • Lightning Web Component UI
  • Reusable architecture

📁 Project Structure


Export-ImportMultipleCustomSettingRecordsUsingLWC/
│
├── force-app/
│   └── main/
│       └── default/
│           ├── classes/
│           └── lwc/
│
├── README.md
└── sfdx-project.json
    

⚙️ Apex Controller


public with sharing class ExportCustomSettingController {

    @AuraEnabled(cacheable=true)
    public static List getCustomSettings() {
        return new List{'Setting A', 'Setting B'};
    }

    @AuraEnabled
    public static String processFile(String fileContent) {
        // Logic to parse CSV and insert records
        return 'File processed successfully';
    }
}
    

💻 LWC Component

HTML


<template>
    <lightning-card title="Custom Settings Export/Import">
        <lightning-button label="Export" onclick={handleExport}></lightning-button>
        <lightning-button label="Import" onclick={handleImport}></lightning-button>
    </lightning-card>
</template>
    

JavaScript


import { LightningElement } from 'lwc';

export default class CustomSetting extends LightningElement {

    handleExport() {
        console.log('Export triggered');
    }

    handleImport() {
        console.log('Import triggered');
    }
}
    


📌 Conclusion

This project helps Salesforce developers understand how to handle bulk data export/import using Lightning Web Components and Apex. It can be extended for Custom Metadata, Objects, or API integrations.

Monday, June 5, 2017

How to Install the Force.com IDE Plug-In in Eclipse.

Install the Force.com IDE Plug-In

Step 1: Launch Eclipse.

Step 2: Select Help → Install New Software.

Step 3:  Click Add button and write in the Add Repository dialog box,
           Name → Force.com IDE
     Locationhttps://developer.salesforce.com/media/force-ide/eclipse45

→ For Spring ’16 (Force.com IDE v36.0) and earlier Force.com IDE versions, use http://media.developerforce.com/force-ide/eclipse42.

→ Click OK.

→ To install an older version of the plug-in (for example, if you don’t have Java 8), deselect Show only the latest versions of available software.

→ Eclipse downloads the list of available plug-ins and displays them in the Available Software dialog.

Step 4:  Select the Force.com IDE plug-in, and then click Next.

Step 5:  In the Install Details dialog, click Next.

Step 6:  In the Review Licenses dialog, accept the terms and click Finish.

→ In step 4, If you choose to install support for Lightning components, Eclipse displays a warning dialog about installing software that contains unsigned content. We are bundling third-party plug-ins to support Lightning components. Salesforce doesn’t own these third-party plug-ins; hence, we don’t sign them. Click OK to proceed.

→ Eclipse downloads and installs the Force.com IDE and the required dependencies. When the installation is complete, you are prompted to restart. Click Yes.

→ When Eclipse restarts, select Window → Open Perspective → Other. Select Force.com and then click OK.

→ You are now ready to develop and customize Force.com applications in Eclipse!



Sunday, June 4, 2017

Apex - Class


Apex - Class

A class is a template or blueprint from which objects are created. An object is an instance of a class. This is standard definition of Class.

→ 3 ways to create apex class in salesforce
  1.   Apex Class
  2.  Apex from Developer Console
  3.  Force.com Eclipse IDE

    From Apex Class:

     Step 1: Click on Setup option. (Top right side on Org)

     Step 2: Search 'Apex Class' in Quick find box and click on Apex Classes link. It will open the Apex Class details page.

      



     Step 3: Click on 'New' button to create new Class.
          



     Step 4: Write code here and then click on save button.
     


From Developer Console:

    Step 1: Go to Name and click on Developer Console.
    Step 2: Click on File menu New and then click on Apex class.

    Step 3: Write Class name and click on OK button.

    Step 4: Write code here.



   From Force.com IDE:
     Step 1: Open Force.com – Eclipse.

    Step 2: Create a New project by clicking on File New Apex Class.

   
    Step 3: Write the Name of Class and click on Finish button.



    Step 4: Once this is done, the new class will be created.

  
    Syntax:
    private | public | global 
    [virtual | abstract | with sharing | without sharing] 
    class ClassName [implements InterfaceNameList] [extends ClassName] 
    { 
      // Classs Body
    }

    Example:

    public class Sampleclass
    {       
         public static Integer a1 = 0; 
         public static Integer getmultiValue()
        {
                 a1 = a1 * 10;
                 return a1;
        }
    }

   


Friday, May 26, 2017

Salesforce Collections.

Salesforce Collections 
(List, Set & Map)

List:
→ List is a collection of elements, Such as primitive data types (String, Integer, Date, etc), user defined objects, sObjects, Apex objects or other collections (can be multidimensional up to 5 levels).
→ List allows duplicate values.
→ List index position starts from zero.

Syntax: List<datatype> listName = new List <datatype>();

List Methods:

1. add()
→ Add value in List.
→ Ex.
     List <string> fruits = new List <string>();
     fruits.add('Apple');
     fruits.add('Orange');
     fruits.add('Banana');
     fruits.add('Grape');

OR

List <string> fruits = new List <string>{'Apple','Orange','Banana','Grape'};

2. get()
→ Retrieve a value from the list using Index.
→ Ex.
     String getfruit = fruits.get(1);
          - We get 'Orange' fruit form list using getfruit variable.

3. set()
→ Replace a value with the value at given Index parameter.
→ Ex.
     fruits.set(3,'Strawberry');  
          - In List value has been changed at the index 3. 'Grape' is replace to 'Strawberry'

4. size()
→ Return the number of elements in the List.
→ Ex.
     fruits.size();
          - Give the size of fruits list is 3.

5. clear()
→ Remove the elements from the list.
→ Ex.
     fruits.clear();          

For more List methods.


Set:
→ Set is a collection of unique, unordered elements.
→ It can contain primitive data types (String, Integer, Date, etc) or sObjects.
→ Set allows unique values.

Syntax: Set<datatype> SetName = new Set <datatype>();

Set Methods:

1. add()
→ Adds an element to the set if it is not already present.

2. contains()
→ Returns true if the set contains the specified element.

3. equals()
→ Compares this set with the specified set and returns true if both sets are equal; otherwise, returns false.

4. size()
→ Returns the number of elements in the set.

5. remove()
→ Removes the specified element from the set if it is present. 

For more Set methods


Map:
→ Map is a collection of key-value pair.
→ Keys can be any primitive data types (String, Integer, Date, etc) while values can include primitives, Apex objects, sObjects and other collections.
→ Map allows duplicate values, but each key must be unique.

Syntax: map<datatype,datatype> MapName = new map <datatype,datatype>();

Map Methods:

1. get(key)
→ Returns the value to which the specified key is mapped, or null if the map contains no value for this key.

2. put(key, value)
→ Associates the specified value with the specified key in the map.

3. remove(key)
→ Removes the mapping for the specified key from the map, if present, and returns the corresponding value.

4. size()
→ Returns the number of key-value pairs in the map.

5. values()
→ Returns a list that contains all the values in the map.

For more Map methods