Skip to main content

Latest Post

Custom Metadata Types vs Custom Settings vs Custom Labels

  Custom Metadata Types vs Custom Settings vs Custom Labels 💬 In plain words:  Three lookalikes: Custom Metadata = configuration that DEPLOYS with your code (best for app settings). Custom Settings = org/user-specific values, changeable at runtime (hierarchy type is great for bypass switches). Custom Labels = translatable text for the UI. 📌 Example:  API endpoint URLs per environment → Custom Metadata (deploys with code, sandbox vs prod values). A 'Bypass_Automation__c' checkbox an admin flips during data load → hierarchy Custom Setting. The word 'Submit' translated to Hindi → Custom Label. 🎬 Real-Life Example: The Fee Table Trapped Inside Code  Skyline charges a different delivery fee per city. Apex needs those rates on every booking. The Old/Bad Way:  if (city == 'Delhi') fee = 50. Else if (city == 'Mumbai') fee = 65. … Every rate change is a code change, a test run, and a deployment. Why this is bad:  Business data is trappe...

Deploy Lightning Web Component Files - Full Code with Output

Introduction:

Lightning Web Components (LWC) are a powerful way to build efficient and reusable components in the Salesforce ecosystem. In this blog, we will walk through the process of deploying Lightning Web Component files and explore the full code with the output. By the end of this tutorial, you will have a clear understanding of how to create, deploy, and test Lightning Web Components.


Prerequisites:


Before proceeding, make sure you have the following prerequisites:

  1. Salesforce Developer Account or Sandbox.
  2. Salesforce CLI installed on your local machine.
  3. Basic knowledge of HTML, JavaScript, and CSS.
  4. Familiarity with Salesforce DX and LWC concepts.

Step 1: Setting Up the Project

  1. Create a new project directory on your local machine.
  2. Open the terminal and navigate to the newly created directory.
  3. Use the Salesforce CLI to create a new Lightning Web Component.

sfdx force:lightning:component:create --type lwc --componentname HelloWorld


Step 2: Develop the Lightning Web Component

  1. Navigate to the newly created "HelloWorld" directory.
  2. Open the "HelloWorld.js" file and replace its content with the following code:

import { LightningElement } from 'lwc';


export default class HelloWorld extends LightningElement {

    greeting = 'Hello, Lightning Web Components!';

}


3. Open the "HelloWorld" file and replace its content with the following code:


<template>

    <p>{greeting}</p>

</template>


Step 3: Deploy the Lightning Web Component


1. In the terminal, deploy the Lightning Web Component to your Salesforce organization using the following command:


sfdx force:source:deploy -p force-app/main/default/lwc/HelloWorld


Step 4: Verify the Deployment

  1. Login to your Salesforce Developer Account or Sandbox.
  2. Open the Lightning App Builder and create a new Lightning Page.
  3. Drag and drop the "HelloWorld" component onto the page.
  4. Save and activate the Lightning Page.
  5. Preview the page to see the deployed Lightning Web Component in action.

Conclusion:


Congratulations! You have successfully deployed a Lightning Web Component to your Salesforce organization and seen the output on a Lightning Page. Lightning Web Components provide a modern and efficient way to build interactive user interfaces within the Salesforce ecosystem. Keep exploring and experimenting with LWC to create powerful and scalable applications.


Remember to always follow best practices when developing and deploying LWCs to ensure optimal performance and maintainability. Happy coding!

Popular Posts

Salesforce LWC Code for Multi-Select Lookup

Introduction: In Salesforce Lightning Web Components (LWC), implementing a multi-select lookup field can enhance the user experience and provide greater flexibility for selecting multiple related records. In this blog post, we will walk through the process of creating a multi-select lookup field using LWC. We will cover the required code snippets and provide step-by-step instructions to help you implement this functionality in your Salesforce org.