Skip to content

Instantly share code, notes, and snippets.

View Sunil02kumar's full-sized avatar

Sunil Kumar Sunil02kumar

View GitHub Profile
<aura:component controller="SkRecordTypeSelectionController">
<aura:attribute name="objType" type="String" required="true" default="Opportunity"/>
<aura:attribute name="selectedRecordType" type="String"/>
<aura:attribute name="recordTypeList" type="Object[]"/>
<aura:handler name="init" action="{!c.doInit}" value="{!this}" />
<div role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<div class="slds-modal__header">
<lightning:buttonIcon class="slds-modal__close" iconName="utility:close" size="large"
<aura:component >
<aura:attribute name="recordId" type="String" required="true"/>
<aura:attribute name="recordInfo" type="Object" access="private"/>
<aura:attribute name="record" type="Object" access="private"/>
<aura:attribute name="recordError" type="String" access="private"/>
<aura:attribute name="currView" type="String" />
<aura:attribute name="accountRecordType" type="String"/>
<aura:attribute name="isRecordDeleted" type="boolean" default="false" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<force:recordData aura:id="recordHandler" recordId="{!v.recordId}" layoutType="FULL"
@Sunil02kumar
Sunil02kumar / Generating URL to pre-populate Contact fields
Last active May 25, 2017 09:57
Generating URL dynamically pre-populate custom fields values while creating new records
/*Now consider a scenario where we want to pre-populate below contact fields:
LastName
Email
Birthdate
Level__c (custom field)
Category__c(custom lookup field)
*/
string redirectUrl='';
String baseURL = Url.getSalesforceBaseUrl().toExternalForm();
@Sunil02kumar
Sunil02kumar / showSpinnerCmp.cmp
Created June 23, 2017 04:44
Lightning Component to show/hide loading spinner image
<aura:component >
<aura:attribute name="show" type="Boolean" default="false" />
<aura:handler name="change" value="{!v.show}" action="{!c.spinnerDisplayHandler}"/>
<div class="slds-align--absolute-center">
<lightning:spinner aura:id="spinner" variant="brand" size="large" class="slds=hide"/>
</div>
</aura:component>
@Sunil02kumar
Sunil02kumar / VFPageApp.app
Created June 25, 2017 10:38
Passing component attribute value from VF page to Lightning component
<aura:application access="GLOBAL" extends="ltng:outApp">
<c:VFPageComponent/>
</aura:application>
@Sunil02kumar
Sunil02kumar / EventForVFPage.evt
Created June 26, 2017 17:17
Firing component event from VF Page in lightning
<aura:event type="COMPONENT" description="Event template" >
<aura:attribute name="valuePassedFromEvent" type="string"/>
</aura:event>
@Sunil02kumar
Sunil02kumar / UtilityClassForSFDC.cls
Created June 28, 2017 06:44
Utility Class to find SFDC current Org API Version
//Utility to find SFDC current Org API Version
public class UtilityClassForSFDC{
public static decimal findAPIVersionOfOrg(){
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
String domainUrl=URL.getSalesforceBaseUrl().toExternalForm();
system.debug('********domainUrl:'+domainUrl);
req.setEndpoint(domainUrl+'/services/data');
@Sunil02kumar
Sunil02kumar / SK_AccListView.cmp
Created July 1, 2017 17:12
Firing Event from Lightning component and handling it in VF page
<aura:component controller="SK_AccListViewController">
<aura:attribute name="recList" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:registerEvent name="skEvent" type="c:SK_AccListViewEvent"/>
<aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
<aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>
<div class="slds-align--absolute-center">
<lightning:spinner aura:id="spinner" variant="brand" size="large" class="slds=hide"/>
</div>
@Sunil02kumar
Sunil02kumar / SK_AccountList.cmp
Last active July 20, 2017 13:25
Inheritance in Lightning Components
<aura:component controller="SK_AccountListController" extends="c:SK_CallToServerUtility">
<aura:attribute type="Object" name="returnedRecords" />
<aura:attribute type="string" name="searchValue" default="" />
<aura:set attribute="msg" value="SK_CallToServerUtility component is inherited in SK_AccountList Component"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div>
<div class="slds-align--absolute-center">
Inherited Component attribute (msg) value set by this component:<b>{!v.msg}</b>
</div>
<br/>
@Sunil02kumar
Sunil02kumar / SK_LocalizationDemo.vf
Created July 28, 2017 06:13
Language Translation in VisualForce Page
<apex:page standardcontroller="Account" extensions="SK_LocalizationDemoController" language="{!selectedLang}" sidebar="false">
<apex:form >
<div >
<div style="float:right">
<apex:selectList value="{!selectedLang}" size="1">
<apex:selectoptions value="{!AvailableLanguages}"/>
<apex:actionsupport event="onchange"/>
</apex:selectlist>
</div>
</div>