Skip to content

Instantly share code, notes, and snippets.

View Sunil02kumar's full-sized avatar

Sunil Kumar Sunil02kumar

View GitHub Profile
@Sunil02kumar
Sunil02kumar / SK_LightningNotificationsNoticeDemoCmp.cmp
Created May 19, 2019 03:01
Lightning:NotificationsLibrary : Easy Way to Display Notices in Lightning
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<lightning:notificationsLibrary aura:id="notifLib"/>
<lightning:button name="notice" label="Display Notice" onclick="{!c.showNotice}"/>
</aura:component>
@Sunil02kumar
Sunil02kumar / SK_PlatformEventHandlerCmp.cmp
Last active May 16, 2019 02:09
Handling Platform Events in Lightning Components
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<!--The empApi component Exposes the EmpJs Streaming API library which provides methods to subscribe and unsubscribe to a platform event channel using CometD(available in API version 44.0 or above)-->
<lightning:empApi aura:id="empApi"/>
<!-- Attribute to store platform event channel name -->
<aura:attribute name="channel" type="String" default="/event/Demo_Event__e"/>
<!--Displays messages via notices and toasts. This component requires API version 41.0 and later.-->
<lightning:notificationsLibrary aura:id="notifLib"/>
<!--Attribute to store object that is returned by the empApi.subscribe() method-->
<aura:attribute name="subscription" type="Map"/>
<!--attribute to show/ hide platform event message-->
@Sunil02kumar
Sunil02kumar / OverAllCodeCoverageScript
Created April 19, 2019 17:34
Script to find Overall Code Coverage of Salesforce Org
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/v43.0/tooling/query/?q=SELECT+PercentCovered+FROM+ApexOrgWideCoverage');
req.settimeout(12000);
req.setMethod('GET');
Http h = new Http();
@Sunil02kumar
Sunil02kumar / ClassOrTriggerCodeCoverageScript
Last active September 23, 2022 10:02
Way to export Code Coverage of Individual ApexClass or Trigger in .csv format
public class apexCodeCoverageWrapper {
public Integer size {get;set;}
public Integer totalSize {get;set;}
public Boolean done {get;set;}
public String entityTypeName {get;set;}
public List<Records> records {get;set;}
}
public class Records {
@Sunil02kumar
Sunil02kumar / SK_UserLocaleInfoApp.app
Created February 16, 2019 05:13
User Locale Information in Lightning Components
<aura:application extends="force:slds">
<c:SK_UserLocaleInfoCmp/>
</aura:application>
<aura:application extends="force:slds">
<c:SK_LightningMapCmp/>
</aura:application>
@Sunil02kumar
Sunil02kumar / DynamicPicklistOptionsUtility.apxc
Created December 22, 2018 02:52
Apex method to find picklist options using describe
public class DynamicPicklistOptionsUtility{
@AuraEnabled
public static List<picklistWrapper> findPicklistOptions(string objAPIName, string fieldAPIname) {
list<picklistWrapper> returnValue = new list<picklistWrapper>();
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
// Get the object type of the SObject.
Schema.sObjectType objType = schemaMap.get(objAPIName);
// Describe the SObject using its object type.
Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
@Sunil02kumar
Sunil02kumar / SK_GenericTreeGridCmp.cmp
Created November 15, 2018 16:34
Generic Component to display Lightning Treegrid
<aura:component controller="SK_GenericTreeGridController">
<aura:attribute name="ltngcurrentRecId" type="String" required="true"/>
<aura:attribute name="ltngSobjectName" type="String" required="true"/>
<aura:attribute name="ltngParentFieldAPIName" type="String" required="true"/>
<aura:attribute name="ltngColumnLabelList" type="List" required="true"
description="provide comma seperated values"/>
<aura:attribute name="ltngColumnAPINameList" type="List" required="true"
description="provide comma seperated values"/>
<aura:attribute name="ltngHyperlinkColumn" type="String"/>
@Sunil02kumar
Sunil02kumar / SK_AuraActionChildCmp.cmp
Created November 5, 2018 07:08
Aura.Action : Lightning Framework Specific Attributes Type
<aura:component >
<aura:attribute name="ltngMessage" type="string"/>
<aura:attribute name="closeChildDivFunction" type="Aura.Action" default="{!c.defaultCloseAction}"/>
<div aura:id="maincontainer" style="background-color:#E6E6FA;border-style: solid;height:100px;margin:2%;padding:1%;">
<b>This is Child component inside SK_AuraActionDemoCmp</b>
<br/>
<lightning:button label="Close via ChildCmp JS function" variant="neutral" onclick="{!c.defaultCloseAction}"/>
<lightning:button label="Close via Parent JS function" variant="brand" onclick="{!v.closeChildDivFunction}"/>
<aura:application extends="force:slds">
<c:SK_AccountTreeGridCmp ltngcurrentRecId="0010K00001qo2mrQAA"/>
</aura:application>