Skip to content

Instantly share code, notes, and snippets.

View toanshulverma's full-sized avatar

Anshul Verma toanshulverma

View GitHub Profile
@toanshulverma
toanshulverma / convertPEJsonToCSV.ps1
Created April 4, 2023 18:45
Convert Salesforce platform event JSON to CSV
# Insert record with attachment
# Usage: ./convertPEJsonToCSV.ps1 -inputFile "./eventjson.json" -output "./uat_event.csv"
param (
[string]$inputFile,
[string]$outputFile
)
# create record
@toanshulverma
toanshulverma / 1-Create Salesforce record and upload an file.md
Last active March 2, 2023 21:40
PS - Create Salesforce Record with attachment

PRE-REQUISITES

  • Install SFDX
  • Authorize target org within SFDX with desired alias

USAGE

Open powershell and fire this command

./createstagingwithattachment.ps1 -objectName [OBJECT NAME] -instanceName [ORG NAME] -objectData [OBJECT FIELD DATA] -attachment [ATTACHMENT FILE]

  • [OBJECT NAME] = api name of the object for which record is to be created
@toanshulverma
toanshulverma / RoleGenerator
Last active February 15, 2020 23:05
Salesforce - Mass generate roles within Salesforce
/*
DESCRIPTION: Genreate roles in Salesforce in bulk. Save your sweat
USAGE: For details go to https://www.vermanshul.com/2020/02/salesforce-quick-tips-mass-upload-roles.html
*/
public with sharing class RoleGenerator {
String topRole;
Map<String, String> mapRoleNames = new Map<String, String>();
@toanshulverma
toanshulverma / DownloadPDF.page
Created December 1, 2018 23:07
Generates and Downloads PDF
<apex:page showHeader="false" standardController="Account">
File is being downloaded. If it doesn't download, <a href="/apex/PDFTestPage" id="lnkDownload" target="_blank" download="PDFTest.pdf" onload="auto_download();">click here</a> to download file.
<script>
function auto_download(){
document.getElementById('lnkDownload').click();
};
//trigger auto-download
window.setTimeout(auto_download, 10);
@toanshulverma
toanshulverma / GeneratePDF.page
Created December 1, 2018 22:43
Generate PDF Within Lightning Experience
<apex:page showHeader="false" standardController="Account" standardStylesheets="false" renderAs="PDF">
Test Document
<img src="http://chart.googleapis.com/chart?cht=bvg&chs=250x150&chd=s:Monkeys&chxt=x,y&chxs=0,ff0000,12,0,lt|1,0000ff,10,1,lt" />
</apex:page>
@toanshulverma
toanshulverma / DataDisplayController.cls
Last active June 20, 2024 23:13
Sample Code to Generate PDF from Lightning components with in-memory data
public class DataDisplayController {
public String PDFData {get; set;}
public DataDisplayController(){
PDFData = '';
}
public PageReference downloadPDF(){
System.PageReference pageRef = new System.PageReference('/apex/PDFGenerator');