Skip to content

Instantly share code, notes, and snippets.

@svierk
svierk / decision-framework.csv
Last active June 9, 2026 19:36
Decision Framework: Apex vs. UI API vs. GraphQL
Scenario Recommended approach
Fetch fields for a known record ID getRecord (UI API)
Display a standard related list getRelatedListRecords (UI API)
Fetch multiple related lists from one parent getRelatedListRecordsBatch (UI API)
Filter records by criteria (no known ID) GraphQL wire adapter
Join data across multiple objects in one request GraphQL wire adapter
Aggregations (COUNT / SUM / etc.) GraphQL wire adapter
Cursor-based pagination for large lists GraphQL wire adapter
Simple create / update / delete (no business logic) executeMutation (GraphQL) or uiRecordApi
DML with validation or triggers you need to control Apex
@svierk
svierk / ui-api-wire-adapters.csv
Last active June 9, 2026 06:05
Salesforce UI API Wire Adapters
Adapter Best for
getRecord Fetching fields for a known record ID
getRecords Fetching fields for multiple known record IDs
getRelatedListRecords Displaying a standard related list
getRelatedListRecordsBatch Multiple related lists from one parent in one call
getListInfoByName Metadata for a list view
getObjectInfo Object schema and field metadata
@svierk
svierk / qrCodeGenerator.js-meta.xml
Created June 5, 2026 11:53
XML file for QR Code Generator LWC
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>66.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>QR Code Generator</masterLabel>
<description>Generate QR Codes with optional logo overlay.</description>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__FlowScreen</target>
@svierk
svierk / qrCodeGenerator.css
Created June 5, 2026 11:52
CSS Styles for QR Code Generator LWC
.spinner-container {
display: flex;
justify-content: center;
padding: 2rem 0;
}
.logo-preview {
display: inline-flex;
align-items: flex-start;
gap: 0.25rem;
@svierk
svierk / qrCodeGenerator.js
Created June 5, 2026 11:49
JS Controller for QR Code Generator LWC
import qrcodejs from '@salesforce/resourceUrl/qrcodejs';
import { loadScript } from 'lightning/platformResourceLoader';
import { LightningElement } from 'lwc';
export default class QrCodeGenerator extends LightningElement {
url = '';
logoDataUrl = null;
logoFileName = '';
qrCodeDataUrl = '';
isLoading = false;
@svierk
svierk / qrCodeGenerator.html
Last active June 5, 2026 11:45
HTML Template for QR Code Generator LWC
<template>
<lightning-card title="QR Code Generator" icon-name="utility:scan">
<div class="slds-var-p-horizontal_medium slds-var-p-bottom_medium">
<lightning-input
type="url"
label="Target URL"
placeholder="https://example.com"
value={url}
onchange={handleUrlChange}
class="slds-var-m-bottom_small"
@svierk
svierk / takeUserProfilePicture.js
Created February 12, 2024 17:02
JS Code for Take User Profile Picture LWC
export default class TakeUserProfilePicture extends LightningElement {
video;
canvas;
renderedCallback() {
this.video = this.template.querySelector('.video');
this.canvas = this.template.querySelector('.canvas');
}
async startCamera() {
@svierk
svierk / takeUserProfilePicture.html
Created February 12, 2024 16:53
HTML Template for Take User Profile Picture LWC
<template>
<lightning-card icon-name="custom:custom38" title="Take User Profile Picture">
<div class="slds-grid slds-gutters">
<div class="slds-col slds-size_1-of-2">
<video class="slds-p-left_small video" autoplay></video>
<canvas class="slds-hide canvas"></canvas>
</div>
<div class="slds-col slds-size_1-of-2">
<img src="" class="slds-p-right_small slds-hide preview" alt="Captured User Photo" />
</div>
@svierk
svierk / UserProfilePictureController.cls
Created February 12, 2024 15:18
Apex Controller class for updating the user's profile picture
public with sharing class UserProfilePictureController {
@AuraEnabled
public static void updateProfilePicture(String base64) {
try {
Blob b = EncodingUtil.base64Decode(base64);
ConnectApi.BinaryInput binaryInput = new ConnectApi.BinaryInput(b, 'image/png', 'UserPhoto.png');
ConnectApi.UserProfiles.setPhoto(null, 'me', binaryInput);
} catch (Exception e) {
System.debug('The following exception has occurred: ' + e.getMessage());
}
@svierk
svierk / contentDocumentTable.js
Last active January 27, 2024 10:55
JS Code for Content Document Table LWC | Columns & Data
export default class ContentDocumentTable extends NavigationMixin(LightningElement) {
@api recordId = null;
@api library = 'Documents';
@api folder = null;
@api showCard = false;
@api cardIcon = 'standard:file';
@api cardTitle = 'Document Table';
@api showDownloadAction = false;
@api showViewAction = false;
@api showDeleteAction = false;