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 / TopicNavigationHelper.js
Created March 31, 2016 00:54
This shows how to work through navigation and encode the Topic Search String
if (component.isValid() && state === "SUCCESS") {
for (i = 0; i < response.getReturnValue().length; i++) {
var topic = {};
topic = { 'sobjectType': 'Topic','Name': '' ,'Id' :'','Label' :''};
topic.Name = encodeURIComponent(response.getReturnValue()[i].Name);
topic.Label = response.getReturnValue()[i].Name;
topic.Id = response.getReturnValue()[i].Id;
topicslst.push(topic);
}
console.log('TOPICS..'+topicslst);
@msrivastav13
msrivastav13 / DataWrapper.cls
Last active August 3, 2016 21:04
LeadHeat Map Controller
public with sharing class DataWrapper {
public integer zoomLevel {get;set;}
public decimal scale {get;set;}
public string title {get;set;}
public decimal latitude {get;set;}
public decimal longitude {get;set;}
public string url {get;set;}
public DataWrapper (integer zoomLevel,decimal scale,
@msrivastav13
msrivastav13 / AccountTest.cls
Last active August 14, 2016 05:07
Simple class to fetch data from SFDC Account Table
public with sharing class AccountTest{
@AuraEnabled
public static list<Account> getlstacc(){
return [Select Id , Name , NumberofLocations__c from Account order by NumberofLocations__c limit 10];
}
}
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);
@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);
@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 / 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 / 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">
<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">
<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>