Skip to content

Instantly share code, notes, and snippets.

@madmax983
madmax983 / CMTService.cls
Last active September 23, 2021 09:54
Apex Stub API with Static Methods
public with sharing class CMTService {
public List<CMTWrapper> getCMTs() {
List<CMTWrapper> cmtWrappers = new List<CMTWrapper>();
List<CMT__mdt> cmts = [SELECT Example_Field_1__c, Example_Field_2_c FROM CMT__mdt];
for(CMT__mdt c : cmts) {
CMTWrapper cmtWrapper = new CMTWrapper(c.Example_Field_1__c, c.Example_Field_2__c);
cmtWrappers.add(cmtWrapper);
}
return cmtWrappers;
@madmax983
madmax983 / PrettyPrintLWCProperties.html
Last active May 21, 2021 18:15
LWC Debugging Tips and Tricks
<template>
{lwcPrettyProperty}
</template>
import { createElement } from "lwc";
import tdd from "c/tdd";
describe("c-tdd", () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
}
});
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSobjectName" access="global" >
<lightning:recordEditForm recordId="{!v.recordId}" objectApiName="{!v.sObjectName}">
<lightning:messages />
<lightning:inputField fieldName="Name" />
<lightning:inputField fieldName="<INSERTNAMESPACEHERE>__LookupField__c" />
<lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" onclick="{!c.handleClick}" />
</lightning:recordEditForm>
</aura:component>
@madmax983
madmax983 / MCVE_Dynamic.cmp
Last active November 16, 2016 19:22
Issues With Force:Input/OuputField
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="record"
type="Opportunity"
default="{ 'sobjectType': 'Opportunity' }"/>
<aura:attribute name="error"
type="String"/>
<aura:attribute name="columns"
type="integer"
description="The number of columns"/>
<aura:attribute name="fields"
@madmax983
madmax983 / ltngDataServiceFun.cmp
Last active October 28, 2016 09:18
Fun with Lightning Data Service
<aura:component >
<aura:attribute name="recordIds"
type="List"
access="public"
description="An array of Ids"/>
<aura:attribute name="records"
type="Map"
description="The records!"
default="{}"/>
<aura:attribute name="errors"