Skip to content

Instantly share code, notes, and snippets.

View Sunil02kumar's full-sized avatar

Sunil Kumar Sunil02kumar

View GitHub Profile
public class SK_LightningDataTableController {
@AuraEnabled
public static List<Account> searchAccountsSOQL(string searchString) {
String queryString = 'Select id, name,type,industry from Account ';
if(searchString!=null && searchString!=''){
searchString = '%'+string.escapeSingleQuotes(searchString)+'%';
queryString = queryString+ 'where Name Like:searchString';
}
queryString = queryString + ' Limit 10000';
List<Account> accList = database.query(queryString);
global class AccountUtility implements OnClickJSUtilityController.OnClickJSHelper{
global OnClickJSUtilityController.onClickJSMessageWrapper executeLogic(string accountId){
OnClickJSUtilityController.onClickJSMessageWrapper wrap = new OnClickJSUtilityController.onClickJSMessageWrapper();
if(accountid!=null && accountId!=''){
try{
Account acc=[select id,name,type,billingCountry,BillingPostalCode from Account where id=:accountId];
if(acc.BillingPostalCode!=null && acc.BillingPostalCode!='' && acc.billingCountry!=null && acc.billingCountry!=''){
acc.type='Prospect';
//this class is created to parse response from box while searching any content on box
public class BoxSearchContentResponseParser {
public Integer total_count {get;set;}
public List<Entries> entries {get;set;}
public Integer limit_Z {get;set;} // in json: limit
public Integer offset {get;set;}
public class Entries {
public String type_Z {get;set;} // in json: type
public String id {get;set;}
public String etag {get;set;}
@Sunil02kumar
Sunil02kumar / MetadataAPIUtility.cls
Last active April 19, 2019 07:54
Create Update Custom Label by Using Metadata API
//Author- Sunil Kumar
public class MetadataAPIUtility{
public static boolean createCustomLabel(string csname,string description,string language,string value, boolean isProtected){
List<MetadataService.Metadata> allMetadataList = new List<MetadataService.Metadata>();
MetadataService.MetadataPort service = createService();
MetadataService.CustomLabel csLabel = new MetadataService.CustomLabel();
csLabel.fullName = csname;
csLabel.language = language;
//Author- sunil Kumar
//@sunil02kumar
// skforce is namespace of my org.
public class MetadataAPICMUtility{
public static boolean createCustomMetadata(){
List<MetadataService.Metadata> allMetadataList = new List<MetadataService.Metadata>();
MetadataService.MetadataPort service = createService();
MetaDataService.CustomMetadata CMTRec = new MetaDataService.CustomMetadata();
//fullname refer custom metadata name.unique name
@Sunil02kumar
Sunil02kumar / SK_LightningAppForVF.app
Created July 12, 2018 17:26
Adding Lightning Components in VF Page and Passing Values from URL
<aura:application extends="ltng:outApp" >
<aura:dependency resource="c:SK_LightningCmpForVF"/>
</aura:application>
@Sunil02kumar
Sunil02kumar / MetadataAPIUtility.cls
Last active December 14, 2018 02:04
Creating Remote Site Settings Using Metadata API
//Author- sunil Kumar
//Twitter handle-@sunil02kumar
//purpose- create remote site setting so that we can call rest api created in same org
public class MetadataAPIUtility{
public static boolean createRemoteSiteSettings(){
boolean isSucessfull=false;
Map<string,string> RemoteSiteMap = new Map<string,string>();
//specify the remote site name and url in RemoteSiteMap
RemoteSiteMap.put('FOR_REST_API_CALL',URL.getSalesforceBaseUrl().toExternalForm());
//String PageURL1 = URL.getCurrentRequestUrl().toExternalForm();
@Sunil02kumar
Sunil02kumar / APICallUtilityVF.page
Last active August 9, 2018 12:20
Finding Session id for User in Future Method or Batch Class
<apex:page showHeader="true" sidebar="true">
SessionIDStart{!$Api.Session_ID}SessionIDEnd
StartVFPageBaseURL{!LEFT($CurrentPage.URL,FIND('/',$CurrentPage.URL,9))}EndVFPageBaseURL
</apex:page>
@Sunil02kumar
Sunil02kumar / SK_ChildCmp.cmp
Created August 12, 2018 09:34
Component Events: Way to Communicate Between Components in Containment Hierarchy
<aura:component >
<aura:attribute name="childValue" type="string" default="Child"/>
<aura:registerEvent name="changeValueEvent" type="c:SK_LightningEventChannel"/>
<lightning:button name="ddff" label="Fire event" onclick="{!c.fireEvent}"/>
</aura:component>
@Sunil02kumar
Sunil02kumar / SK_ApplicationEventPracticeApp.app
Last active August 19, 2018 01:22
Application Events : Way to Communicate Between Different Lightning Components
<aura:application extends="force:slds">
<c:SK_FirstComponent/>
<c:SK_SecondComponent/>
</aura:application>