Skip to content

Instantly share code, notes, and snippets.

View kevanmoothien's full-sized avatar

Kevan kevanmoothien

View GitHub Profile
@kevanmoothien
kevanmoothien / VisualforcePdf_w_HeaderFooter.md
Last active March 21, 2023 10:53
A visualforce template with header and footer for pdf
<apex:page applyHtmlTag="false"
           showHeader="false"
           renderAs="pdf">
    <html>
        <head>
            <style>
                @page {
@kevanmoothien
kevanmoothien / UploadContentDocument.md
Last active April 17, 2021 14:47
A visualforce page sample to upload content document to a specific record
<apex:page showHeader="false" applyHtmlTag="true" applyBodyTag="false">
    <apex:includeScript value="https://code.jquery.com/jquery-2.2.4.js" />
    <script>
        var PARENT_ID = '0010800002t8mrYAAQ'; //change Id to your record Id
        jQuery(document).ready(function ($) {
            $('input#file').on('change', function (e) {
                for (var i = 0; i < this.files.length; i++) {
                    uploading += 1;
                    upload_file(this.files[i], PARENT_ID, function (err, res) {
@kevanmoothien
kevanmoothien / list_id.md
Last active April 5, 2020 13:20
Get the list of record ids from Salesforce sobject records.

Common way

List<Contact> contacts = [Select Id, Name from Contact];
List<Id> contactIds = new List<Id>();
for(Contact c: contacts){
    contactIds.add(c.Id);
}

One line only

@kevanmoothien
kevanmoothien / csv copy
Created March 28, 2019 08:07
Read csv column and copy file to another folder
```bash
cat annotations.csv|while read line
do
read -d, col1 <<(echo $line)
echo "$col1"
cp "./$col1" "./images/$col1"
done
```

Apex Controller

public class CasePriority {
    @RemoteAction
    public static list<Case> getCases(string priority) {
        list<Case> cases = [Select Id, CaseNumber, Subject, Description, Priority, Status 
                              From Case 
                              Where Priority = :priority
                              And Status = 'New'
@kevanmoothien
kevanmoothien / dump_heroku_postgres.md
Created July 1, 2018 14:59
dump database from heroku to localhost
@kevanmoothien
kevanmoothien / VisualforceRenderAsPdf_template.xml
Created February 17, 2018 11:57
A visualforce template for rendering pdf from Salesforce
<apex:page applyHtmlTag="false"
showHeader="false"
renderAs="pdf">
<html>
<head>
<style>
@page {
size: A4
}
</style>
<apex:page renderAs="pdf">
</apex:page>
@kevanmoothien
kevanmoothien / EnvelopeContactAddressPrint.xml
Last active February 16, 2018 12:28
Render a Visualforce as Pdf
<apex:page standardController="Contact"
applyHtmlTag="false"
showHeader="false"
renderAs="pdf">
<html>
<head>
<style>
@page {
size: 6.4in 4.5in;
}

OpportunityMenu.cmp

<aura:component implements="force:appHostable">
    <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
    <aura:handler name="init" value="{!this}" action="{!c.navHome}"/>
</aura:component>

OpportunityMenuController.js