Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
swapnilshrikhande / README.md
Last active January 25, 2019 12:23
Generic Redirect Utility

Usage :

var redirectURL    = getRedirectURL(redirectPage,linkType);
var redirectTo_url = redirectTo('{!recordId}',redirectURL, openInSubtab, actionLabel, linkType );
@swapnilshrikhande
swapnilshrikhande / app.js
Created January 2, 2019 10:47
Simple Table Filter
$(document).ready(function () {
$('.star').on('click', function () {
$(this).toggleClass('star-checked');
});
$('.ckbox label').on('click', function () {
$(this).parents('tr').toggleClass('selected');
});
@swapnilshrikhande
swapnilshrikhande / Gemfile
Created December 23, 2018 02:42
Jekyll Gemfile
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
@swapnilshrikhande
swapnilshrikhande / use_cases_dashboard.txt
Last active November 30, 2018 13:40
Test Case Execution Dashboard
ApexClass[] testClasses = [SELECT Id FROM ApexClass WHERE Name LIKE 'EditOpportunityServiceTest'];
ApexTestQueueItem[] queueItems = new List<ApexTestQueueItem>();
for (ApexClass cls : testClasses)
queueItems.add(new ApexTestQueueItem(ApexClassId=cls.Id));
//it will submit them for execution
insert queueItems;
Id recordId = queueItems[0].Id;
queueItems = [Select Id,Status,ExtendedStatus,TestRunResultID from ApexTestQueueItem Where Id=: recordId];
System.debug(queueItems[0].TestRunResultID);
Id runResultId = queueItems[0].TestRunResultID;
interface TestDataGenerator {
public SObject createRecord(String objectName);
public List<String> getRequiredFields(String objectName);
public Map<String,String> getTestData(String objectName);
}
public class DefaultTestDataGenerator implements TestDataGenerator {
}
@swapnilshrikhande
swapnilshrikhande / EchoService.java
Last active November 20, 2018 10:58
Eternus Training Session : REST Code Snippets
@RestResource(urlMapping='/echo/*')
global class EchoService {
@HttpGet
global static String helloWorld() {
return 'Hello, Eternus!';
}
@HttpPost
global static String echo() {
@swapnilshrikhande
swapnilshrikhande / RestUtility.cls
Created November 12, 2018 08:28
Simple Rest Utility To help consume a rest service from salesforce.
/*
How to use RestUtility
1. RestUtility.URL_ENCODE_PARAMS to true if you wish to encode the url parameters,
by default they are not encoded.
2. getAuthorizationHeader(String username,String password) to use basic authentication method.
*/
public with sharing class RestUtility {
public static final String BASIC = 'Basic ';
public static Boolean URL_ENCODE_PARAMS = false;
frn.formatMoney = function(){
$("[format-currency]").each(function(){
var currency = function(amount){
return amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
}
try{
if( $(this).is("input") ){
var amount = parseFloat( $(this).val() );
@swapnilshrikhande
swapnilshrikhande / getFieldsOfType.apex
Created September 28, 2018 12:01
Get Field List By Type
public Map<String,String> handleDateTypes(Map<String,String> recordMap,Type classType){
List<String> dateTimeFields = getFieldsOfType(
classType
, Schema.SOAPType.DATE
);
for( String fieldKey : recordMap.keySet() ){
if( dateTimeFields.contains(fieldKey.toLowerCase()) ){
String dateValue = recordMap.get(fieldKey);
@swapnilshrikhande
swapnilshrikhande / getFieldsOfType.apex
Created September 28, 2018 12:01
Get Field List By Type
public Map<String,String> handleDateTypes(Map<String,String> recordMap,Type classType){
List<String> dateTimeFields = getFieldsOfType(
classType
, Schema.SOAPType.DATE
);
for( String fieldKey : recordMap.keySet() ){
if( dateTimeFields.contains(fieldKey.toLowerCase()) ){
String dateValue = recordMap.get(fieldKey);