Skip to content

Instantly share code, notes, and snippets.

View msrivastav13's full-sized avatar
🎯
Focusing

Mohith Shrivastava msrivastav13

🎯
Focusing
View GitHub Profile
@msrivastav13
msrivastav13 / CommunityBuilderPickListUtil
Created February 19, 2018 18:14
Gets the Field Picklist labels and values from the Object Metadata
global class CommunityBuilderPickListUtil extends VisualEditor.DynamicPickList{
global override VisualEditor.DataRow getDefaultValue(){
VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('Product Family', 'Product Family');
return defaultValue;
}
global override VisualEditor.DynamicPickListRows getValues() {
VisualEditor.DynamicPickListRows myValues = new VisualEditor.DynamicPickListRows();
Schema.DescribeFieldResult fieldResult = Product2.Family.getDescribe();
@msrivastav13
msrivastav13 / searchAppV2
Created January 15, 2018 21:32
searchAppV2
<aura:application extends="force:slds">
<c:searchCmp />
</aura:application>
@msrivastav13
msrivastav13 / searchApp
Last active January 15, 2018 21:13
Code to Show LockerService In action
<aura:application extends="force:slds">
<c:searchCmp />
</aura:application>
<aura:component >
implements="lightning:actionOverride,force:hasRecordId,force:hasSObjectName">
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
<aura:attribute name="test" type="String"/>
{!v.test}
<lightning:button label="Edit" onclick="{!c.handleEdit}"/>
</aura:component>
<aura:component
implements="lightning:actionOverride,force:hasRecordId,force:hasSObjectName">
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media--center slds-has-flexi-truncate">
<div class="slds-media__body">
<h2><span class="slds-text-heading--small">Answer Below Questions to Proceed to Account Creation?</span></h2>
</div>
</header>
<div class="slds-no-flex">
@msrivastav13
msrivastav13 / GridLighntingComponent
Last active April 8, 2017 23:11
Grid 0.0.0.0.0001
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="ApexMetadataUtility">
<aura:attribute name="metadata" type="SobjectMetadataWrapper[]"/>
<aura:handler name="init" value="{!this}" action="{!c.getresults}" />
<div class="slds-tree_container" role="application">
<h4 class="slds-text-title--caps" id="treeheading">Objects</h4>
<aura:iteration items="{!v.metadata}" var="cardItem">
<ul class="slds-tree" role="tree" aria-labelledby="treeheading">
<li id="tree0-node0" role="treeitem" aria-level="1">
<div class="slds-tree__item">
@msrivastav13
msrivastav13 / ApexMetadataUtility
Last active April 9, 2017 01:00
Metadata Wrapper over apex metadata
public with sharing class ApexMetadataUtility {
/**
* Call apex controller method fetch metadata
* @param
* @return void
*/
@AuraEnabled
public static list<SobjectMetadataWrapper> getSobjectMetadata(String[] sobjectarray){
list<SobjectMetadataWrapper> lstsobjectMetadata = new list<SobjectMetadataWrapper>();
@msrivastav13
msrivastav13 / StandardDeviationComputation
Created March 21, 2017 00:38
Simple apex Utility to calculate Standard Deviation
public with sharing class StandardDeviationComputation {
public static decimal getStandardDeviation(Integer precision){
AggregateResult[] groupedResults = [SELECT COUNT(Id),SUM(DistanceSquare__c) FROM Survey__c GROUP BY Standard_Deviation__c ];
decimal sumOfDistanceSquare = (decimal)groupedResults[0].get('expr1');
integer count = (integer)groupedResults[0].get('expr0');
if(count > 0){
return system.Math.sqrt(sumOfDistanceSquare/count).setScale(precision);//Scale is kept at 3 currently
}else{
return 0;
}
@msrivastav13
msrivastav13 / ContactList.Controller
Last active November 21, 2016 04:51
Fetching Contacts Via Lightning Component
({
fetchContactList : function(component, event, helper) {
var action = component.get("c.getContacts");
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.contacts", response.getReturnValue());
}
});
$A.enqueueAction(action);
public with sharing class AccountTest{
@AuraEnabled
public static list<AccountWrapper> getlstacc(){
list<AccountWrapper> lstWrapper = new list<AccountWrapper>();
for(Account acc :[Select Id , Name , NumberofLocations__c from Account order by NumberofLocations__c limit 10]){
AccountWrapper accWrap = new AccountWrapper();
accWrap.Name = acc.Name;
accWrap.noOfLocations = integer.valueof(acc.NumberofLocations__c);
lstWrapper.add(accWrap);