This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Trigger to update the Total__c and Record_Count__c fields of parent records A__c | |
// when child records B__c are inserted, updated, undeleted or deleted. | |
trigger RollUpBOnA on B__c ( | |
after insert, | |
after update, | |
after delete, | |
after undelete | |
) { | |
// Declare a set to store the Ids of the parent object A__c | |
Set<Id> parentIds = new Set<Id>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* UpdateContactCountOnAccount Trigger | |
* ---------------- | |
* This trigger is designed to update the Number_of_Contacts__c field on the Account object | |
* whenever a Contact record is inserted, updated, deleted, or undeleted. | |
* The purpose is update the Number_of_Contacts__c field on the related Account record. | |
* Key Features: | |
* - Identifies Contact records linked to an Account record (via AccountId). | |
* - Counts the number of Contact records for each Account record. | |
* - Updates the Number_of_Contacts__c field on the Account record. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* RollUpBOnA Trigger | |
* ---------------- | |
* This trigger is executed after a B__c record is inserted, updated, deleted, or undeleted. | |
* The purpose is to update the Total__c and Record_Count__c fields on the related A__c record. | |
* Key Features: | |
* - Identifies B__c records linked to an A__c record (via A_No__c). | |
* - Counts the number of B__c records and sums their Value__c field for each A__c record. | |
* - Updates the Total__c and Record_Count__c fields on the A__c record. | |
* - Ensures any updates made re-trigger workflows or additional triggers, if applicable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description - This batch class createS contacts for accounts created in the last 7 days. | |
* It tracks success and error records and sends an email with the results as CSV attachments. | |
*/ | |
public class ContactCreationBatch implements Database.Batchable<sObject>, Database.Stateful { | |
// Stateful variables to track results | |
private List<ContactWrapper> successList; | |
private List<ContactWrapper> failureList; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description - This batch class updates the description of Account records created today. | |
* It tracks success and error records and sends an email with the results as CSV attachments. | |
*/ | |
public class AccountUpdateBatch implements Database.Batchable<sObject>, Database.Stateful { | |
// Stateful variables to track results | |
private List<String> successRecords; | |
private List<String> errorRecords; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-else-return */ | |
// Import the required modules | |
import { LightningElement, api } from "lwc"; | |
import getFieldTypes from "@salesforce/apex/GenericRecordController.getFieldTypes"; | |
import getRecords from "@salesforce/apex/GenericRecordController.getRecords"; | |
import { NavigationMixin } from "lightning/navigation"; | |
import { ShowToastEvent } from "lightning/platformShowToastEvent"; | |
import { loadStyle } from "lightning/platformResourceLoader"; | |
import customStyle from "@salesforce/resourceUrl/datatableStyle"; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<!-- Rendering a Lightning card --> | |
<lightning-card title=""> | |
<!-- Displaying a Lightning spinner --> | |
<template if:true={showSpinner}> | |
<div id="spinnerDiv" style="height: 10rem"> | |
<div class="slds-spinner_container"> | |
<div role="status" class="slds-spinner slds-spinner_medium"> | |
<span class="slds-assistive-text">Loading</span> | |
<div class="slds-spinner__dot-a"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @Description : The EncryptionCtrl class is a public Apex class that enforces sharing rules, | |
* meaning it respects the user's sharing settings when accessing data. | |
* It contains methods for retrieving and decrypting an AES key and handling | |
* encrypted card numbers. The MY_KEY constant holds a sample encryption key, | |
* which can be accessed in test classes due to the @TestVisible annotation. | |
*/ | |
public with sharing class EncryptionCtrl { | |
// Define a private static constant string MY_KEY, which holds a sample encryption key. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--HTML File: Data Input and Submission Button--> | |
<!-In the following code, we create an LWC that masks the credit card number on the UI. | |
It encrypts the actual value before sending it to Apex.--> | |
<template> | |
<lightning-card title="Encryption In LWC"> | |
<div class="slds-m-around_medium"> | |
<lightning-combobox name="cardType" label="Card Type" placeholder="Please select..." | |
options={cardTypes} onchange={handleChange} required> | |
</lightning-combobox> | |
<lightning-input name="cardNumber" type="text" label="Card Number" min-length="15" max-length="16" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ContactTrigger | |
* ---------------- | |
* This trigger is executed after a Contact record is updated. | |
* The purpose is to update the Title of a Contact to include a reference to the related Account's Name. | |
* | |
* Key Features: | |
* - Identifies Contacts linked to an Account (via AccountId). | |
* - Queries the related Account's Name and updates the Contact's Title to reference it. | |
* - Ensures any updates made re-trigger workflows or additional triggers, if applicable. |