Skip to content

Instantly share code, notes, and snippets.

<aura:component implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" extensible="true">
<aura:method name="execApex" action="{! c.execApex }">
<aura:attribute name="callingComponent" type="Aura.Component" default="{! this }" />
<aura:attribute name="method" type="String" />
<aura:attribute name="params" type="Map" />
</aura:method>
{! v.body }
@sohalloran
sohalloran / EmailSend.cmp
Created July 30, 2018 17:08
Email Handling for Opportunity
<aura:component controller="EmailSendController" implements="force:lightningQuickAction,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">
<!--Part 1 [for attribute declare]-->
<aura:attribute name="email" type="string"/>
<aura:attribute name="subject" type="string"/>
<aura:attribute name="body" type="string"/>
<aura:attribute name="mailStatus" type="boolean" default="false"/>
<!---Part 2 [header part] -->
<div class="slds-page-header" role="banner">
<h1 class="slds-page-header__title slds-m-right--small slds-align-middle slds-truncate" title="this should match">
@sohalloran
sohalloran / ErrorLoggingSvc.cmp
Last active May 1, 2018 15:15
Lightning Logging Service Component
<aura:component >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="newLogRec" type="Error_Log__c" />
<aura:attribute name="newLog" type="Error_Log__c" />
<aura:attribute name="logError" type="string" description="Error message returned by logging service" />
<force:recordData aura:id="errorLogCreator"
layoutType="FULL"
targetRecord="{!v.newLogRec}"
@sohalloran
sohalloran / AccountsList.cmp
Last active May 1, 2018 14:26
Reuseable Lightning Data Service Component
<aura:component extends="c:DataSvc" controller="AccountsListController">
<aura:attribute name="rows" type="Object[]" description="The row data."/>
<aura:attribute name="columns" type="List" default="[{label:'Id', fieldName: 'Id', type: 'text'},{label:'Name', fieldName: 'Name', type: 'text'}]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:datatable data="{!v.rows}" keyField="Id" columns="{!v.columns}"/>
</aura:component>
//CONTROLLER
<aura:event type="COMPONENT">
<aura:attribute name="message" type="String"/>
</aura:event>
@sohalloran
sohalloran / MathSvc.cmp
Created April 30, 2018 19:49
*Using a Service Component Example App*
<aura:component >
<aura:method name="add" action="{!c.add}" access="public">
<aura:attribute name="numbers" type="Double[]"/>
</aura:method>
<aura:method name="square" action="{!c.square}" access="public">
<aura:attribute name="number" type="Double"/>
</aura:method>
</aura:component>
// Controller //
var action = component.get("c.getItems");
action.setStorable();
action.setCallback(this, function(response) {
// handle response
};
$A.enqueueAction(action);
@sohalloran
sohalloran / OpportunityTrigger.trigger
Created April 30, 2018 13:39
Opportunity Programatic Share - Reinsert Shares after ownership change
trigger OpportunityTrigger on Opportunity (before update) {
Set<Id> ownerChangeOppIds = new Set<Id>();
for (Opportunity opp : Trigger.new) {
if(opp.ownerId != Trigger.oldMap.get(opp.Id).OwnerId) {
ownerChangeOppIds.add(opp.Id);
}
}
if(!ownerChangeOppIds.isEmpty()) {
String oppShares = JSON.serialize([select opportunityId, UserOrGroupId, OpportunityAccessLevel, RowCause
from OpportunityShare
@sohalloran
sohalloran / Email2Case.apex
Last active July 5, 2017 17:29
Email2Case
global class Email2Case implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String body = email.plainTextBody;
Case newCase = new Case();
newCase.SuppliedEmail = parse(body,'EMAIL:',false);
newCase.SuppliedName = parse(body,'LAST NAME:',false);
newCase.Description = 'Accepted Terms: ' + parse(body,'ACCEPTED TERMS',false) + ' Receive Further Info: ' + parse(body,'RECEIVE FURTHER INFO',false) + ' ' + parse(body,'MESSAGE:',true);
newCase.Subject = 'Email from ' + parse(body,'EMAIL:',false);
insert newC
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="React by Example - Components">
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="http://fb.me/react-with-addons-0.14.3.js"></script>
<script src="http://fb.me/react-dom-0.14.3.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">