Skip to content

Instantly share code, notes, and snippets.

View srujan21's full-sized avatar

GANGASRUJAN GURUDU srujan21

View GitHub Profile
@srujan21
srujan21 / Import Fonts
Created February 9, 2017 11:09
Code to import fonts
@font-face {
font-family: myFont;
src: url({!URLFOR($Resource.MyZipFile, '/root/to/font.ttf')});
}
p {
font-family: myFont;
}
//You could put them in a .zip folder, upload them as a static resource and use @font-face to call them in your CSS.
@srujan21
srujan21 / EmailLogic.cls
Created December 7, 2017 10:16 — 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)) +
@srujan21
srujan21 / custom_attribite.cmp
Last active October 1, 2019 08:24
Set custom attribute on component and Retrieve that in controller
<div class="slds-truncate" style ="text-align : center;" title="{!$Label.c.Selection}" data-selected-Index = "{!com.key}" onclick ="{!c.setKey}">
<lightning:input aura:id="selectedRange" name="radioButton" type="radio"/>
</div>
@srujan21
srujan21 / show_checkbox.page
Created October 10, 2019 06:02
Show the unchecked and checked checkbox in visualforce PDF
<apex:page showHeader="false" renderAs="PDF" cache="true" >
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
@page{
size:A4 portrait;
@bottom-right {
content: "Page " counter(page) " - " counter(pages);
font-family: 'Arial', 'Helvetica', sans-serif;
@srujan21
srujan21 / validateController.js
Last active October 14, 2019 16:48
Validating form fields on Lightning Aura component
var page1ReqFields = ['lastName','firstName','prefix','birthDate','gender','homePhnNum','pmAddres','pmCity','pmState','pmZip'];
// aura Ids of required fields
@srujan21
srujan21 / CreateSalesforceFile
Created October 17, 2019 16:08
Insert Salesforce file and link it to sobject
PageReference pg = Page.EHSC_OSB_PDF;
pg.getParameters().put('id', oppId);
ContentVersion conVer = new ContentVersion();
conVer.ContentLocation = 'S'; // S specify this document is in SF, use E for external files
conVer.PathOnClient = 'OSB '+DateTime.now().getTime()+'.pdf'; // The files name, extension is very important here which will help the file in preview.
conVer.Title = 'OSB '+DateTime.now().getTime()+'.pdf'; // Display name of the files
if(!Test.isRunningTest()){
conVer.VersionData = pg.getContentAsPDF();
}
else{
@srujan21
srujan21 / AccountUpdateBatchJob
Created December 31, 2019 07:01
Sample Batch job along with test class
global class AccountUpdateBatchJob implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'SELECT Id,Name FROM Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
@srujan21
srujan21 / MergeEmailTemplate
Created January 8, 2020 17:06
Merge record data in email template
public static string renderEmailTemp(Id objctId, List<String> bodies){
// Id of the sObject, list of Email template bodies
List<Messaging.RenderEmailTemplateBodyResult> renderEmailTemplateBodyRes= Messaging.renderEmailTemplate(null,objctId, bodies);
return renderEmailTemplateBodyRes[0].getMergedBody();
}
@srujan21
srujan21 / getSelectOptions
Last active January 24, 2020 16:10
Show Picklist in Lightning component
public static List <String> getselectOptions(sObject objObject, string fld) {
system.debug('objObject --->' + objObject);
system.debug('fld --->' + fld);
List < String > allOpts = new list < String > ();
// Get the object type of the SObject.
Schema.sObjectType objType = objObject.getSObjectType();
// Describe the SObject using its object type.
Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
// Get a map of fields for the SObject
map < String, Schema.SObjectField > fieldMap = objDescribe.fields.getMap();
@srujan21
srujan21 / ScheduledBatchClassTemplate
Created January 29, 2020 05:29
A Template for writing Scheduled Batch job in apex
/**
* @File Name : CreateMissingContactUserLinkController.cls
* @Description :
* @Author :
* @Group :
* @Last Modified By :
* @Last Modified On : 2020-01-29 15:32:43
* @Modification Log :
* Ver Date Author Modification
* 1.0 2020-01-29 Srujan Initial Version