Skip to content

Instantly share code, notes, and snippets.

@j-schreiber
j-schreiber / production-build-job.yml
Last active January 18, 2021 11:11
CircleCi config.yml for a workflow that tests the source on a scratch org, builds a package and deploys to staging and production.
jobs:
build_and_install_production:
executor:
name: sfdx-default
steps:
- checkout
- sfdx/install
- run:
name: Setup SFDX CLI
command: |
@j-schreiber
j-schreiber / pdf-template-dynamic-component.cls
Created July 9, 2020 06:40
Dynamic component property on the pdf controller class
public static Component.Apex.PageBlock DynamicAddress {
public get {
if (DynamicAddress == null && Template != null && String.isNotBlank(Template.AddressFormatting__c)) {
DynamicAddress dynAddr = new DynamicAddress(Template.AddressFormatting__c);
dynAddr.RecordVariableName = 'QuoteRecord';
DynamicAddress = dynAddr.getAddressAsPageBlock();
}
return DynamicAddress;
}
private set;
@j-schreiber
j-schreiber / pdf-visualforce-dynamic-date.html
Created July 9, 2020 06:39
Visualforce snippet with a dynamically formatted date output text
<apex:outputText value="{!DateFormatting}">
<apex:param value="{! Record.Your_Date_Field__c }" />
</apex:outputText>
@j-schreiber
j-schreiber / pdf-template-date-formatting.cls
Created July 9, 2020 06:37
Date formatter property of pdf template
public static String DateFormatting {
public get {
if (DateFormatting == null) {
if (String.isNotBlank(Template.DateFormatting__c)) {
DateFormatting = '{0, date, '+ Template.DateFormatting__c +'}';
} else {
DateFormatting = '{0, date, dd.MM.yyyy}';
}
}
return DateFormatting;
@j-schreiber
j-schreiber / pdf-template-dynamic-stylesheet.html
Last active July 9, 2020 06:42
PDF Visualforce page that uses the template property to dynamically load the formatting css
<apex:variable rendered="{! Template.LetterFormat__c != NULL }" var="LetterFormat" value="{! Template.LetterFormat__c }">
<apex:stylesheet value="{! URLFOR($Resource[Template.LetterFormat__c]) }" />
</apex:variable>
@j-schreiber
j-schreiber / pdf-controller-template-property.cls
Last active July 9, 2020 06:43
Template Property on the PDF Controller
public static PdfTemplate__c Template {
public get {
if (Template == null && TemplateId != null) {
Template = [SELECT Id,AddressFormatting__c,DateFormatting__c,Description__c,IsActive__c,LetterFormat__c,TaxDisplayOptions__c FROM PdfTemplate__c WHERE Id = :TemplateId];
}
return Template;
}
private set;
}
@j-schreiber
j-schreiber / LetterFormat__c.field-meta.xml
Created July 8, 2020 11:44
Custom picklist field with css static resources as names
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
[...]
<valueSet>
<restricted>true</restricted>
<valueSetDefinition>
<sorted>false</sorted>
<value>
<fullName>DIN_5008_Type_A</fullName>
<default>true</default>
@j-schreiber
j-schreiber / din-5008-letter.css
Last active July 8, 2020 11:41
CSS snippet to format a printed visualforce page as ANSI letter
/** DIN 5008 (Type A) with margins and paddings */
@page {
size: A4 portrait;
margin: 27mm 0mm 32mm 0mm; /** These margins control size of header and footer */
padding: 5mm 0mm; /** Paddings for content page area to header/footer */
}