Skip to content

Instantly share code, notes, and snippets.

View sfcure's full-sized avatar
🎯
Focusing

sfcure

🎯
Focusing
View GitHub Profile
<aura:event type="COMPONENT" description="On record selection">
<aura:attribute name="childObjectName" type="String"/>
<aura:attribute name="fieldName" type="String"/>
<aura:attribute name="selectedRecordId" type="String"/>
</aura:event>
@sfcure
sfcure / DependentPicklist.html
Created May 23, 2019 10:41
Dependent Picklist Based on Record Types
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
access="global"
controller="DependentPicklistController">
<!-- Event Handlers -->
<aura:handler name="init" value="this" action="{!c.doInit}"/>
<!-- Attributes-->
<aura:attribute name="listControllingValues" type="list" default="[]" description="to store controller field values"/>
<aura:attribute name="listDependingValues" type="list" default="['--- None ---']" description="to store dependent field values"/>
<aura:component implements="force:appHostable,lightning:isUrlAddressable" >
<aura:attribute name="recordId"
type="String"
description="ID of the record."/>
<aura:handler name="init"
value="this"
action="{!c.doInit}"/>
</aura:component>
@sfcure
sfcure / SampleApp.app
Last active March 29, 2019 02:54
Using Lightning Component in a Visualforce page
<aura:application access="global" extends="ltng:outApp" >
<c:SampleComp />
</aura:application>
<script>
var country_arr = new Array("Afghanistan", "Albania", "Algeria", "American Samoa", "Angola", "Anguilla", "Antartica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Ashmore and Cartier Island", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Clipperton Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czeck Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Eur
@sfcure
sfcure / quickAction.html
Created October 1, 2018 11:08
Quick Action Component CSS
<aura:html tag="style">
.slds-modal__container{
height : auto; width: 80%; max-width: 70vh;
}
.modal-body{
height : 40vh !important;
max-height: 40vh !important;
}
.slds-modal__footer{
display: inline !important;
@sfcure
sfcure / LightningRecordEditForm.xml
Last active April 18, 2021 07:12
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="">
<aura:component access="global">
<aura:attribute name="record" type="sObject" description="record which is being displayed"/>
<aura:attribute name="field" type="Object" description="field object which is being rendered"/>
<aura:attribute name="cellValue" type="Object"/>
<aura:attribute name="cellLabel" type="String"/>
<aura:attribute name="isTextField" type="boolean" default="false"/>
<aura:attribute name="isReferenceField" type="boolean" default="false"/>
<aura:attribute name="isDateField" type="boolean" default="false"/>
<aura:attribute name="isDateTimeField" type="boolean" default="false"/>
<aura:attribute name="isCurrencyField" type="boolean" default="false"/>
@sfcure
sfcure / SOQLService.cls
Created July 27, 2018 14:26
Creating a dynamic SOQL which includes all the fields
Map<String,Schema.SObjectField> mapFields = Account.getSObjectType().getDescribe().fields.getMap();
List<String> fieldNames = new List<String>();
for( String fieldName : mapFields.keySet() ) {
fieldNames.add( fieldName );
// For relationship fields
if( Schema.DisplayType.Reference == mapFields.get(fieldName).getDescribe().getType() )
fieldNames.add( mapFields.get(fieldName).getDescribe().getRelationshipName() + '.Name' );
}
String query =
' SELECT ' +
@sfcure
sfcure / NamespaceDemoComp.html
Created July 27, 2018 14:22
How to use namespace in managed lightning components
<aura:component controller="NamespaceDemoCompController" implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="namespace" type="String"/>
<aura:attribute name="totalAmount" type="Decimal"/>
Total Amount : {!v.totalAmount}
</aura:component>