Skip to content

Instantly share code, notes, and snippets.

danic85 / gist:de627813450c9b5a8b176c11c6b4e0e6
Last active November 23, 2016 13:40
Lightning Select component markup with select inside iteration.
View gist:de627813450c9b5a8b176c11c6b4e0e6
<aura:attribute name="selectOptions" type="object[]" description="A list of objects with value (ID) and text (label) attributes"/>
<aura:attribute name="selectedOption" type="ID" default="" description="The value of the selected option"/>
<lightning:select name="selectName" label="My Select" value="{!v.selectedOption}" onchange="{!c.doSomething}" required="true">
<aura:iteration items="{!v.selectOptions}" var="option">
<option value="{!option.value}" selected="{!if(v.selectedOption==option.value,'selected','')}">{!option.text}</option>
danic85 / gist:d56e11650783e7fd6f635e962da3d79b
Created November 23, 2016 10:16
Control visibility of lightning component using slds-hide
View gist:d56e11650783e7fd6f635e962da3d79b
<!-- Component Markup -->
<div aura:id="yourIdentifier">
<c:Your_Component />
* Controller Method
showComponent : function (component, event, helper) {
$A.util.removeClass(component.find("yourIdentifier"), "slds-hide");
danic85 / gist:4c48f7dd1d4532049b491c8cd1d47f31
Created December 7, 2016 14:46
Binding lightning:input checkbox value. Must bind to 'checked' not 'value'
View gist:4c48f7dd1d4532049b491c8cd1d47f31
<aura:attribute name="testBoolean" type="Boolean" default="false" />
<lightning:input name="testBoolean" label="Test Boolean" type="checkbox" checked="{!v.testBoolean}" />
danic85 / gist:cf71ce35e2cc25b273ff6be6a75b6d48
Created December 15, 2016 16:34
SLDS Wizard Progress Bar - Bar will not display without z-index on containing div
View gist:cf71ce35e2cc25b273ff6be6a75b6d48
<span class="slds-wizard__progress" style="z-index: 0;">
<span class="slds-wizard__progress-bar" style="width:50%;"></span>
danic85 / gist:a5519c6591bce94cf4e7c7064506c50b
Last active August 7, 2017 08:36
Lightning FLS. Throw exception if any field is not accessible.
View gist:a5519c6591bce94cf4e7c7064506c50b
List<String> fields = new List<string>(); // Add your fields to check here
String objectName = ''; //Add your object name here
Map<String,Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap()
for (String fieldToCheck : fields) {
// Check if the user has access to view field
if (!fieldMap.get(fieldToCheck).getDescribe().isAccessible()) {
//also pass error to client
throw new System.NoAccessException();
danic85 / outputproxy.js
Created February 26, 2018 16:15
Convert a proxy to a readable object
View outputproxy.js
outputProxy : function(record) {
var obj = {};
for(var propt in record) {
obj[propt] = record[propt];
if (typeof(record[propt]) == 'object') {
obj[propt] = this.outputProxy(record[propt]);
return obj;
danic85 / urlformat.js
Created March 5, 2018 11:14
Detect Lightning URL Format
View urlformat.js
View cancelScheduledJobs.cls
/* Cancel Scheduled Jobs in Apex */
for(CronTrigger delCron: [SELECT Id FROM CronTrigger ]) {
danic85 / onewire.ino
Created June 12, 2018 12:04
Reading from a 1-wire device (DS28E05) with arduino.
View onewire.ino
/* YourDuino Example: Find Address of a DS18B20 Temperature Sensor
Cut and paste the address to a text file for later use.
V1.1 01/17/2013
DS18B20 Pinout (Left to Right, pins down, flat side toward you)
- Left = Ground
- Center = Signal (Pin 2): (with 3.3K to 4.7K resistor to +5 or 3.3 )
danic85 / TestComponent.cmp
Last active June 14, 2018 10:28
Salesforce Lightning: Setting a conditional default value blocks any further changes to the attribute.
View TestComponent.cmp
<aura:component implements="flexipage:availableForAllPageTypes">
<aura:attribute name="myString" type="string" default="{!if(false, 'Default Val', 'Other Default')}"/>
<aura:attribute name="mySimpleString" type="string" default="Default Val"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div class="slds-card">
{!v.myString} <!-- Will always output 'Other Default', even if changed later by doInit -->
{!v.mySimpleString} <!-- Will be changed to 'Set Directly' by doInit -->