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 ),
import { LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import ChatResource from '@salesforce/resourceUrl/Chat_Application_LWC';
export default class Chat_Application extends LightningElement {
renderedCallback() {
Promise.all([
loadScript(this, ChatResource + '/js/jquery.min.js'),
loadScript(this, ChatResource + '/js/jquery.mCustomScrollbar.min.js'),
global class AccountEmailService implements Messaging.InboundEmailHandler {
public static Schema.DescribeSObjectResult objectDescribe = Account.getSObjectType().getDescribe();
public static Map<String, Schema.SObjectField> fields;
static{
fields = objectDescribe.fields.getMap();
}
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
global class AccountEmailService implements Messaging.InboundEmailHandler {
//describe call on Account object to fetch all fields and their Data type
public static Schema.DescribeSObjectResult objectDescribe = Account.getSObjectType().getDescribe();
public static Map<String, Schema.SObjectField> fields;
static{
fields = objectDescribe.fields.getMap();
}
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
@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)) +
/*
var imag = e.target.result;
let attach = {};
attach['fileName'] = component.get('v.storeName')+'.'+that.name.split('.')[1];//that.name;
attach['contentType'] = that.type;
attach['Body'] = imag.match(/,(.*)$/)[1];
record.fileToBeUploaded.push(attach);
*/
console.log('==i am here==');
// blob stuff
@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();