Skip to content

Instantly share code, notes, and snippets.

@lfreeland
lfreeland / gist:33209d07e38d0f68eb34788a1ee4c220
Created March 18, 2018 20:18
Lightning Record Video Viewer Component Controller
({
init: function(cmp, event, helper) {
var recordId = cmp.get('v.recordId');
var videoField = cmp.get('v.videoField');
if (!recordId || !videoField) {
console.log('The record id or video field is missing.');
return;
}
@lfreeland
lfreeland / gist:693d4922ea480b295c072de56a8c308b
Last active March 18, 2018 23:48
Lightning Record Video Viewer Component Designer
<design:component >
<design:attribute name="videoField" label="Video Field" description="The api name of the field from the given object that has the video's source URL." />
<design:attribute name="videoHeight" label="Video Height" description="The height for the video. Any CSS value is acceptable." default="400px" />
<design:attribute name="videoWidth" label="Video Width" description="The width for the video. Any CSS value is acceptable." default="100%" />
</design:component>
@lfreeland
lfreeland / gist:b929c4c28af02315db975884a2b0be2b
Last active March 18, 2018 23:48
Lightning Record Video Viewer Component Markup
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" controller="RecordVideoViewerController">
<aura:attribute name="videoField" type="String" description="The api name of the field from the given object that has the video's source URL." />
<aura:attribute name="videoHeight" type="String" description="Height for the video player." />
<aura:attribute name="videoWidth" type="String" description="Width for the video player." />
<aura:attribute name="videoSrcUrl" type="String" access="private" />
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<div class="slds-box slds-theme_default">
@lfreeland
lfreeland / gist:e001dfc292d9a29e2383b42b8218511c
Created February 25, 2018 10:44
FeatureManagement Has Custom Permission Access
Boolean hasCustomPermission = FeatureManagement.checkPermission('<custom_permission_api_name>');
if (hasCustomPermission) {
// Allow custom feature
}
@lfreeland
lfreeland / gist:a5a766446d71ddce4308cfec677526a3
Created February 24, 2018 14:58
Lightning Field Set Form V2 Apex Controller
public with sharing class FieldSetFormControllerV2 {
@AuraEnabled
public static FieldSetForm getForm(Id recordId, String objectName, String fieldSetName) {
FieldSetForm form = new FieldSetForm();
form.Fields = getFields(recordId, objectName, fieldSetName);
return form;
}
private static List<Field> getFields(Id recordId, String objectName, String fieldSetName) {
@lfreeland
lfreeland / gist:a227a9366a7d76b025ab6a7b8c2336a4
Last active February 24, 2018 14:57
Lightning Field Set Form V2 Design
<design:component >
<design:attribute name="fieldSetName" label="Field Set Name" description="API Name of the field set to use." />
<design:attribute name="sObjectName" label="Object Name" description="API Name of the Object to use. This only needs to be populated when not on a record detail page." />
<design:attribute name="recordTypeId" label="Record Type Id" description="Id of the record type to use for the given Object." />
</design:component>
@lfreeland
lfreeland / gist:05fffb51b862c4d24cb574b42a24d9d9
Created February 24, 2018 14:56
Lightning Field Set Form V2 Style
.THIS {
background-color: white;
padding: 1rem;
}
@lfreeland
lfreeland / gist:b99eda78d472420c82ac198a9266a223
Created February 24, 2018 14:55
Lightning Field Set Form V2 Controller
({
init: function(cmp, event, helper) {
console.log('FieldSetFormController.init');
var fieldSetName = cmp.get('v.fieldSetName');
var sobjectName = cmp.get('v.sObjectName');
var recordId = cmp.get('v.recordId');
if (!fieldSetName) {
console.log('The field set is required.');
@lfreeland
lfreeland / gist:ae21e962d49a3558fea997f251cf2757
Created February 24, 2018 14:53
Lightning Field Set Form V2 Markup
<aura:component controller="FieldSetFormControllerV2" implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName,flexipage:availableForAllPageTypes">
<aura:attribute name="fieldSetName" type="String" description="The api name of the field set to use from the given object." />
<aura:attribute name="recordTypeId" type="String" />
<aura:attribute name="fields" type="Object[]" access="private" />
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:handler event="force:refreshView" action="{!c.init}" />
<lightning:recordEditForm aura:id="test"
@lfreeland
lfreeland / gist:29046c58c5d4b7cece8f2a8d21b339dd
Created September 17, 2017 17:37
showToast Lightning Controller Code
handleToastEvent : function(component, event, helper) {
var toastMessageParams = event.getParams();
var message = toastMessageParams.message;
if (message.includes('<object_name>') && message.includes('was saved')) {
// do something here such as reload your component.
}
}