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
/** | |
* What it does: | |
Defines a nested FileWrapper class that holds: | |
fileName: Name of the file. | |
mimeType: MIME type like application/pdf or image/png. | |
base64Data: Encoded file content as a base64 string. | |
The method getFileAsBlob(): | |
Fetches the most recent ContentDocumentLink for the given parentId. | |
Retrieves the latest ContentVersion for that ContentDocumentId. | |
Converts the binary data to a Base64 string. |
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> | |
<lightning-card title="Download File From Rest Api Response" icon-name="utility:download"> | |
<div class="slds-p-around_medium"> | |
<template if:true={isLoading}> | |
<lightning-spinner alternative-text="Loading ZIP..." size="medium"></lightning-spinner> | |
</template> | |
<lightning-button | |
label="Download" | |
onclick={handleDownload} | |
disabled={isLoading} |
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
/** | |
* What it does: | |
The method getAttachmentsAsZip(): | |
Accepts a parentId, which is the ID of the record (e.g., a Case or Account) whose attachments we want to fetch. | |
Queries for all attachments associated with that record. | |
Uses the Compression.ZipWriter to create a ZIP archive containing all attachments. | |
Returns the ZIP file as a Base64-encoded string, which can be used in a Lightning Web Component (LWC) to trigger a download. | |
*/ | |
public with sharing class FilesDownloaderCtrl { | |
/** |
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
/** | |
* What it does: | |
The method getAttachmentDownloadUrl(): | |
Accepts a parentId, which is the ID of the record (e.g., a Case or Account) whose attachment we want to fetch. | |
Queries for the most recently modified Attachment associated with that record. | |
Constructs and returns a standard Salesforce file download URL using the Attachment ID: | |
/servlet/servlet.FileDownload?file=<AttachmentId> | |
This URL will trigger the browser to download the file when opened. | |
*/ | |
public with sharing class FilesDownloaderCtrl { |
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
/** | |
* What it does: | |
Defines a nested FileWrapper class that holds: | |
fileName: Name of the file. | |
mimeType: MIME type like application/pdf or image/png. | |
base64Data: Encoded file content as a base64 string. | |
The method getAttachmentAsBlob(): | |
Fetches the most recently updated Attachment record for the given parent record. | |
Converts the binary content (Body) to base64. | |
Wraps it into a FileWrapper object and returns it to the frontend. |
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
//LazyLoadingContactController.apex | |
public class LazyLoadingContactController { | |
@AuraEnabled(cacheable=true) | |
public static List<Contact> getAllContacts() { | |
return [ | |
SELECT Id, FirstName,LastName, Email | |
FROM Contact WHERE Name Like 'E%' LIMIT 1000]; | |
} | |
} |
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
public without sharing class CaseController { | |
@AuraEnabled(cacheable=true) | |
public static List<AggregateResult> getCaseData(String statuses) { | |
List<String> statusList = String.isNotBlank(statuses) ? statuses.split(',') : null; | |
return [ | |
SELECT Status, COUNT(Id) | |
FROM Case | |
WHERE Status IN :statusList | |
GROUP BY Status | |
]; |
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
/** | |
* ContactGrabber Apex Class | |
* This class provides methods to retrieve related contacts for an account, | |
* and fetch account details. | |
*/ | |
public with sharing class ContactGrabber { | |
/** | |
* Retrieves all contacts related to a given account. | |
* @param acctId The Id of the account for which to retrieve related contacts. | |
* @return A list of Contact records related to the specified account. |
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
<!--childValidation.html--> | |
<template> | |
<div> | |
<div id="test" data-id="test1"></div> | |
<lightning-card title="Child Validation Example"> | |
<div class="slds-m-around_medium"> | |
<lightning-input | |
label="Name" | |
data-id="nameField" | |
class="textareaclass" |
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
/** | |
* StudentApiCalloutAction | |
* ---------------------- | |
* @description | |
* This Apex class is designed to perform a callout to an external API to fetch user data based on | |
* the university name provided as input. It processes the response and organizes the data into | |
* a list of Contact records, which are then returned to the caller. | |
* | |
* Key Features: | |
* - Uses the `@InvocableMethod` annotation to allow invocation from Flow or Process Builder. |
NewerOlder