Skip to content

Instantly share code, notes, and snippets.

View Sunil02kumar's full-sized avatar

Sunil Kumar Sunil02kumar

View GitHub Profile
@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 / 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 / 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>
//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 / 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;
//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;}
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';
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);
public class SK_sortUtilityTestWrapper implements Comparable{
public string category{get;set;}
public decimal count{get;set;}
public SK_sortUtilityTestWrapper(string ss,decimal sk){
this.category=ss;
this.count=sk;
}
// Compare wrapper based on the count value.
public Integer compareTo(Object compareTo) {
public class SK_WrapperSortUtility {
//We will sort wrapper list based on count value
//using bubble sort
public static List<SK_sortUtilityTestWrapper> sortWrapperList(List<SK_sortUtilityTestWrapper> recList,string sortType){
List<SK_sortUtilityTestWrapper> sortedList = new List<SK_sortUtilityTestWrapper>();
system.debug('******sortedList before sorting in '+sortType+':'+recList);
if(recList.size()>0){
sortedList = recList;
if(sortType.equalsIgnoreCase('DESC')){