Skip to content

Instantly share code, notes, and snippets.

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="LightningRecordEditFormController">
<aura:attribute name="disabled" type="Boolean" default="false" />
<aura:attribute name="layoutSections" type="List" />
<aura:attribute name="saved" type="Boolean" default="false" />
<aura:attribute name="showSpinner" type="Boolean" default="true" />
<aura:attribute name="fieldName" type="String" default="StageName" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:card title="">
@swapnilshrikhande
swapnilshrikhande / LightningRecordEditForm.xml
Created February 16, 2021 12:22 — forked from sfcure/LightningRecordEditForm.xml
This is a working example of rendering Lightning:RecordEditForm dynamically as per object's page layout
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="LightningRecordEditFormController">
<aura:attribute name="disabled" type="Boolean" default="false" />
<aura:attribute name="layoutSections" type="List" />
<aura:attribute name="saved" type="Boolean" default="false" />
<aura:attribute name="showSpinner" type="Boolean" default="true" />
<aura:attribute name="fieldName" type="String" default="StageName" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:card title="">
@swapnilshrikhande
swapnilshrikhande / HttpMock.cls
Created November 2, 2020 13:23 — forked from rsoesemann/HttpMock.cls
apex-http-mock
@IsTest
public class HttpMock implements HttpCalloutMock {
private static final String ANY_URL = null;
private Map<String, Map<String, Object>> responses = new Map<String, Map<String, Object>>();
// PUBLIC
@swapnilshrikhande
swapnilshrikhande / ManageContentFolder.cls
Last active October 23, 2020 11:21
Example to create salesforce workspace folders programmatically.
@testSetup
private static void createTestData() {
ContentWorkspace testWorkspace = new ContentWorkspace(Name='TEST CLASS', DeveloperName='TEST_CLASS');
insert testWorkspace;
}
@isTest
private static void testGetFilesList(){
ContentWorkspace testWorkspace = [Select Id from ContentWorkspace where Name = 'TEST CLASS'];
public virtual class GenericTrigger {
public SObject[] recordOldList;
public SObject[] recordNewList;
public Map<Id, SObject> recordOldListMap;
public GenericTrigger(SObject[] recordOldList, SObject[] recordNewList) {
this.recordNewList = recordNewList == null ? new SObject[] {} : recordNewList.clone();
this.recordOldList = recordOldList == null ? new SObject[] {} : recordOldList.clone();
this.recordOldListMap = new Map<Id, SObject> {};
String join(List<String> values) {
List<String> valueCopy = new List<String>(values);
if(valueCopy.isEmpty())
return null;
String result = valueCopy[0];
valueCopy.remove(0);
while(!valueCopy.isEmpty()) {
result += ',' + valueCopy[0];
valueCopy.remove(0);
}
@swapnilshrikhande
swapnilshrikhande / AttachFile.cls
Created May 28, 2020 03:52
Cloning Related Files, Here relating files from related case record to lead
trigger AttachFile on Lead (after insert) {
List<ContentDocumentLink> cdeInsertList = new List<ContentDocumentLink>();
System.debug('line3');
Map<Id, Id> caseId2 = new Map<Id, Id>();
for(Lead ldItr : Trigger.New) {
caseId2.put(ldItr.Case__c, ldItr.Id);
}
System.debug('line8');
for(ContentDocumentLink cdl : [SELECT
@swapnilshrikhande
swapnilshrikhande / CaseCreationService.cls
Last active May 19, 2020 15:53
Twilio Salesforce Simple Chat Bot Integration WARNING : Hardcoded data & No Error Handling
without sharing public class CaseCreationService {
//Queries
//How do we autoselect the product ? chat ?
//If no contact found should we create one ?
//How do we link the product
private final Case caseRecord = new Case();
private String contactName;
@swapnilshrikhande
swapnilshrikhande / OpportunityBatchable.cls
Last active May 7, 2020 09:49
Apex Batch Class Template
/**
* @File Name : CreateMissingContactUserLinkController.cls
* @Description :
* @Author :
* @Group :
* @Last Modified By :
* @Last Modified On : 2020-01-29 15:32:43
* @Modification Log :
* @Param
* @Return