This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RemoveWhiteSpace { | |
public String remvoeWhiteSpaceFromString(String strVal) { | |
return strVal.deleteWhitespace(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fibonacci { | |
public String getnerateFibbonaci(Integer num) { | |
String fibobonaciSeries = 'Fibonacci Series: '; | |
Integer f1 = 0, f2 = 1, nextNum = 0; | |
for(Integer i=0;i<num;i++) { | |
nextNum = f1 + f2; | |
f1 = f2; | |
f2 = nextNum; | |
fibobonaciSeries += ', '+String.valueOf(nextNum); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LeapYear { | |
public Boolean isLeapYear(Integer year) { | |
Boolean isTrue = false; | |
if ( math.mod(year,400) == 0 || math.mod(year,4) == 0) | |
isTrue = true; | |
return isTrue; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SwapNumbers { | |
public void doNumSwapping(Integer a, Integer b) { | |
a = a + b; | |
b = a - b; | |
a = a- b; | |
system.debug('a value: '+a); | |
system.debug('b value: '+b); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DynamicSobjectCreation { | |
public static SObject createDynamicObject(String objectApiName) { | |
return (SObject)Type.forName(objectApiName).newInstance(); | |
} | |
public static List createDynamicList4object(String objectApiName) { | |
return (List)Type.forName('List<'+objectApiName+'>').newInstance(); | |
} | |
/*** Usage *** | |
List recs = DynamicSobjectCreation.createDynamicList4object('Contact'); | |
SObject rec1 = DynamicSobjectCreation.createDynamicObject('Contact'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class FieldsValidator implements Database.Batchable<Sobject> { | |
global Database.queryLocator start(Database.BatchableContext bc) { | |
return Database.getQueryLocator('select name, fields_info__c, fields_count__c from ObjectsExistingFieldsInfo__c'); | |
} | |
global void execute(Database.BatchableContext bc, List<SObject> sobjLst) { | |
String[] types = new String[]{'Account','Contact'}; | |
String emailBody = ''; | |
// Make the describe call | |
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(types); | |
Map<String,List<Field>> objFieldsDesMap = new Map<String,List<Field>>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Demo_LightningSortableDatatableContrl { | |
@AuraEnabled | |
public static List<Sobject> fetchOpps(String sortField, String sortOrder) { | |
String query = 'select id, name, stagename, amount from Opportunity'; | |
if(String.isNotBlank(sortField) && String.isNotBlank(sortOrder)) { | |
query += ' order by '+sortField+' '+sortOrder; | |
} | |
return Database.query(query); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component controller="Demo_LightningSortableDatatableContrl"> | |
<aura:attribute name="opportunities" type="list"/> | |
<aura:attribute name="sortField" type="String" default="Name"/> | |
<aura:attribute name="sortOrder" type="String" default="Asc"/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<table class="slds-table slds-table_bordered" role="grid"> | |
<thead> | |
<tr class="slds-line-height_reset"> | |
<th aria-sort="none" class="slds-is-sortable slds-text-title_caps" aria-label="Name" scope="col"> | |
<a class="slds-th__action slds-text-link_reset" href="javascript:void(0);" role="button" tabindex="-1" onclick="{!c.sortColumn}" id="Name" onmouseover="{!c.arrowOnHover}" onmouseout="{!c.arrowOnOut}"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(component, event, helper) { | |
helper.handleDoInit(component, event); | |
}, | |
sortColumn : function(component, event, helper) { | |
var target; | |
if(event.currentTarget.id) | |
target = event.currentTarget.id; | |
component.set("v.sortField",target); | |
if(component.get("v.sortOrder")) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleDoInit : function(cmp, event) { | |
var action = cmp.get("c.fetchOpps"); | |
action.setParams( | |
{ | |
sortField : cmp.get("v.sortField"), | |
sortOrder : cmp.get("v.sortOrder") | |
} | |
); |
OlderNewer