Skip to content

Instantly share code, notes, and snippets.

@sfdevmaster
sfdevmaster / AccountPagenationController.java
Last active May 15, 2025 05:39
Add Pagination In HTML Table in Salesforce Lightning Web Component (LWC) using JavaScript
/**
* AccountPaginationController
* ----------------------------
* This Apex controller is used for retrieving a paginated list of Account records.
*
* Key Features:
* - Retrieves specific fields from the Account object.
* - Enforces field-level security using WITH SECURITY_ENFORCED.
* - Orders the Account records by the Name field for consistent display.
* - Designed for use with Aura or Lightning Web Components (LWC) via @AuraEnabled.
@sfdevmaster
sfdevmaster / AccountFormController.java
Last active May 15, 2025 05:40
Different ways to bind picklist values in Lightning Web Components (LWC)
/**
* AccountFormController
* ----------------------
* This Apex controller provides utility methods for retrieving metadata-related information
* about the Account object, specifically the picklist values for the Rating field.
*
* Key Features:
* - Retrieves and formats picklist values for use in Lightning components.
* - Uses field metadata to ensure consistent and dynamic picklist value retrieval.
* - Designed for use with Aura or Lightning Web Components (LWC) via @AuraEnabled.
@sfdevmaster
sfdevmaster / CollectionUtils.java
Last active May 16, 2025 05:51
Utility Class to Create Maps
/**
* CollectionUtils
* ----------------------
* @description
* A library of generic, type-safe collection methods for transforming and working with
* lists of SObjects. This utility is designed to simplify the conversion of SObject collections
* into keyed Maps, supporting nested field access and maintaining type safety.
*
* Key Features:
* - Converts lists into Maps using specified fields as keys.
/**
* OpportunityValidationTrigger
*
* This trigger is responsible for validating the Opportunity record data before insert or update.
* The trigger checks for disallowed characters in the Opportunity's string and text area fields.
* If a disallowed character is found, an error message is added to the Opportunity record.
*/
trigger OpportunityValidationTrigger on Opportunity(before insert, before update) {
// Regular expression to match disallowed characters
@sfdevmaster
sfdevmaster / disConnectedCallbackChildLwc.html
Last active April 26, 2025 08:32
Disconneced Call Back Example - LWC
<!--disConnectedCallbackChildLwc.html-->
<template>
<p>Child Component</p>
</template>
@sfdevmaster
sfdevmaster / constructorEx.html
Last active April 24, 2025 09:50
Constructor Example - LWC
<!--constructorEx.html-->
<template>
<lightning-card title="Constructor Example - LWC">
<div style="padding: 1rem;">
<lightning-button label="Sample Button"></lightning-button>
</div>
</lightning-card>
</template>
@sfdevmaster
sfdevmaster / customButtonStyles.css
Last active April 24, 2025 09:55
Rendered Call Back Example - LWC
/* Custom css needed to be added to static resources named customButtonStyle*/
.custom-lightning-button {
background-color: #ff5733; /* Custom background color */
color: white; /* Custom text color */
border-radius: 8px; /* Rounded corners */
font-size: 16px; /* Adjust font size */
padding: 10px 20px; /* Custom padding */
}
@sfdevmaster
sfdevmaster / child.css
Last active April 25, 2025 15:50
LWC Lifecycle Hook Connected Callback Example
/*child.css*/
/*applying style to host directly*/
:host {
display: block;
padding: 1rem;
margin: 1rem;
transition: all 0.3s;
}
/*applying style to host using a class*/
:host(.child-host) {
@sfdevmaster
sfdevmaster / testLWC.html
Created April 24, 2025 02:07
LWC Lifecycle Hook Constructor Example
<template>
<lightning-button label="Sample Button"></lightning-button>
</template>
/*serverSideLazyLoadingInDataTableWithScrollBar.css*/
.container {
padding: 0.5rem;
}
.table-container {
border: 1px solid #d8dde6;
background-color: #fff !important;
overflow-y: auto;
min-height: 90px;
}