Skip to content

Instantly share code, notes, and snippets.

Contact c = new Contact();
c.lastName = 'Andy The Customer';
c.Email = 'andy@theCustomerEmailAddress.com';
insert c;
Case theCase = new Case();
insert theCase;
EmailMessage theEmailMessage = new EmailMessage();
theEmailMessage.BccAddress = 'compliance@mostexcellentsoftware.com';
<apex:page standardController=”Case” extensions=”DragAndDropController” >
<apex:slds > 
<apex:form > 
<apex:actionFunction name=”redirectToDragAndDropEmailAuthor” action=”{!goToEmailDragAndDrop}” /> 
</apex:form>
</apex:slds>
<script>
document.addEventListener(‘readystatechange’, event => { 
if (event.target.readyState === “interactive”) {
public class DragAndDropController
{
public String bccAddresses {get; set;}
public String ccAddresses {get; set;}
public String toAddresses {get; set;}
public String caseId {get; set;}
public String caseIdChosen {get; set;}
public String contactIdToEmail {get; set;}
public String externalComments {get; set;}
public String htmlBody {get; set;}
function sendAccountNames(cellData) {
Visualforce.remoting.Manager.invokeAction(
CSVParser.insertAccounts(cellData,
function(result, event) {
console.log('@@@ result is: ' + result);
console.log('@@@ event is: ' + event);
}));
}
global class CSVParser
{
@RemoteAction
global static void insertAccounts(List<String> accountNames)
{
system.debug('The Account Names from the .csv are: ' + accountNames);
List<Account> accounts = new List<Account>();
Account account;
<apex:page controller="CSVParser" docType="html-5.0" lightningStylesheets="false" showHeader="false" sidebar="false" standardStylesheets="false">
<head lang="en">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" />
<apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.js"/>
<!--<apex:includeScript value="{!$Resource.papaparse2}"/>-->
<link rel="stylesheet" href="https:maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https:maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<div class="main">
({
doInit : function(component, event, helper) {
console.log('the doInit was called');
var fullURL = window.location.href;
var recordTypeId = fullURL.substring(fullURL.indexOf("recordTypeId") + 13,fullURL.indexOf("recordTypeId") + 31);
console.log('the recordTypeId is: ' + recordTypeId);
if (recordTypeId != null) {
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,force:lightningquickActionWithoutHeader">
<aura:attribute name="RecordTypeId" type="String" access="public"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:recordEditForm aura:id="recordEditForm" recordId="{!v.RecordId}" recordTypeId="{!v.RecordTypeId}" objectApiName="Account" class="slds-p-top_small">
<span class="slds-hide slds-required" aura:id="required">*</span>
<lightning:inputField aura:id="picklist" fieldName="Industry" />
<lightning:inputField fieldName="RecordId" value="{!v.RecordId}" class="slds-hide" />
<lightning:inputField fieldName="RecordTypeId" value="{!v.RecordTypeId}" class="slds-hide" />
</lightning:recordEditForm>
<!--<lightning:recordEditForm aura:id="recordEditForm" recordId="{!v.RecordId}" recordTypeId="{!v.RecordTypeId}" objectApiName="Account" class="slds-p-top_small">
// Too many DML's issue:
List<Account> accountList = new List<Account>();
Account accountObject;
for (Integer i = 0; i < 150; i++)
{
accountObject = new Account();
accountObject.Name = 'Test ' + i;
accountList.add(accountObject);
}
insert accountList;
// SOQL in a for loop issue:
List<Account> accounts = [SELECT Id, Name FROM Account];
List<Integer> contactCount = new List<Integer>();
for (Integer i = 0; i <= accounts.size(); i++)
{
Integer count = [SELECT COUNT() FROM Contact WHERE AccountId IN : accounts ];
contactCount.add(count);
}
// SOQL in a for loop fix: