Skip to content

Instantly share code, notes, and snippets.

View RatanPaul's full-sized avatar
💭
I may be slow to respond.

Ratan Paul (http://ratanpaul.github.io/) RatanPaul

💭
I may be slow to respond.
View GitHub Profile
@RatanPaul
RatanPaul / ApexCsvExample.java
Created July 7, 2020 09:57 — forked from douglascayers/ApexCsvExample.java
Apex CSV Example. Note the use of String.escapeCsv() method
String csv = 'Id,Name\n';
for ( List<Account> accts : [ SELECT id, name FROM Account LIMIT 10 ] ) {
for ( Account acct : accts ) {
csv += acct.id + ',' + acct.name.escapeCsv() + '\n';
}
}
ContentVersion file = new ContentVersion(
title = 'accounts.csv',
versionData = Blob.valueOf( csv ),
@RatanPaul
RatanPaul / EmailLogic.cls
Created April 29, 2020 08:00 — forked from jsullivanlive/EmailLogic.cls
Salesforce Email Merge
public class EmailLogic {
public static String renderTemplate(sObject sobj, String template) {
for (String fieldName : fields(sobj.getSObjectType())) {
String key = '{!' + fieldName + '}';
while (template.containsIgnoreCase(key)) {
try {
Integer foundPosition = template.indexOfIgnoreCase(key, 0);
template = template.left(foundPosition) +
String.valueOf(sobj.get(fieldName)) +
@RatanPaul
RatanPaul / gist:5d624edf9a50c197638ff8914ed44122
Created March 28, 2018 10:58 — forked from douglascayers/gist:aa2c3d07560e1cde3df6
JQuery Autocomplete Plugin styled with Salesforce Lightning Design System (SLDS) in Visualforce
<apex:page >
<!-- good ol' jquery! -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<script>$j = jQuery.noConflict();</script>
<!-- the infamous SLDS, aka my nemesis -->
<apex:stylesheet value="{!URLFOR($Resource.SLDS0121,'assets/styles/salesforce-lightning-design-system-vf.css')}"/>
@RatanPaul
RatanPaul / salesforce-calendar-view.md
Created February 5, 2018 08:37 — forked from sjurgis/salesforce-calendar-view.md
FullCalendar calendar view implementation in Salesforce.com

This is an adaptation of Cody Sechelski's Create a Calendar View in Salesforce.com.

The main problem with his implementation was that it wasn't handling more than 2000 records. This was due to a Apex workaround, as it is reserves start and end variables, Cody made a repeat table and parsed that into JavaScript object. My solution creates JSON string in Apex and then uses string function to replace all startString and endString instances. A more sensible solution would involve recreating the object in JavaScript or simply editing the FullCalendar library to look for different variable names.

I have also simplified the code a bit so you can start working towards your personal implementation. As this is using JavaScript remoting, I hope this gives you a framework to work towards more advanced features like editing or optimizing request sizes (executing a request on next month load).

The page

<apex:page showHeader="fals
@RatanPaul
RatanPaul / MyDropdownList.js
Created September 7, 2016 07:33 — forked from cosminnicula/MyDropdownList.js
Salesforce Lightning Design System: custom PickList
'use strict';
import React from 'react';
import Menu from 'ui/components/menus/index.react';
import componentUtil from 'app_modules/ui/util/component';
import MyPickList from 'MyPickList';
import RootCloseWrapper from 'react-overlays/lib/RootCloseWrapper';
const pf = componentUtil.prefix;
const PT = React.PropTypes;
@RatanPaul
RatanPaul / read-write-file.js
Created August 4, 2016 06:19
Read Write to file with javascript
/// write to file
var txtFile = "c:/test.txt";
var file = new File(txtFile);
var str = "My string of text";
file.open("w"); // open file with write access
file.writeln("First line of text");
file.writeln("Second line of text " + str);
file.write(str);
file.close();
@RatanPaul
RatanPaul / react-table-component.js
Created April 4, 2016 11:07 — forked from ChaseWest/react-table-component.js
React Table Component for creating a very basic html table
var Table = React.createClass({
render: function render() {
var _self = this;
var thead = React.DOM.thead({},
React.DOM.tr({},
this.props.cols.map(function (col) {
return React.DOM.th({}, col);
})));
<apex:page standardStylesheets="false" showHeader="false" applyHtmlTag="false" docType="html-5.0">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<meta charset="UTF-8" />
<title>Hello React</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<apex:includeScript value="//cdn.rawgit.com/mattwelch/makeDeferredProvider/master/makeDeferredProvider.min.js"/>
<apex:stylesheet value="//cdn.rawgit.com/mailtoharshit/LightingDesignSystem/master/salesforce-lightning-design-system-v0.8.0/assets/styles/salesforce-lightning-design-system-vf.min.css" />
@RatanPaul
RatanPaul / VisualforceDrilldownChart.page
Created March 2, 2016 12:09 — forked from sohalloran/VisualforceDrilldownChart.page
Visualforce Charting with drill down when clicking on chart sections/bars
<apex:chart height="300" width="300" data="{!data}”>
<apex:axis type="Category" position="bottom" fields="ctype">
<apex:chartLabel rotate="270"/>
</apex:axis>
<apex:axis type="Numeric" position="left" fields="cval"/>
<apex:barSeries axis="left" orientation="vertical" xField="ctype" yField="cval">
<apex:chartTips rendererFn="renderer"/>
</apex:barSeries>
</apex:chart>
@RatanPaul
RatanPaul / CustomAccountLookup.page
Created February 17, 2016 12:12 — forked from jeffdonthemic/CustomAccountLookup.page
Roll Your Own Salesforce "Lookup" Popup Window blog post
<apex:page controller="CustomAccountLookupController"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="Account"
id="pg">
<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">