\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Fernando (taurenhunter)} \pdfinfo{ /Title (salesforce-development.pdf) /Creator (Cheatography) /Author (Fernando (taurenhunter)) /Subject (Salesforce Development Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{1CB2FC} \definecolor{LightBackground}{HTML}{F0FAFE} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Salesforce Development Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Fernando (taurenhunter)} via \textcolor{DarkBackground}{\uline{cheatography.com/133929/cs/27477/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Fernando (taurenhunter) \\ \uline{cheatography.com/taurenhunter} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 10th April, 2021.\\ Updated 1st May, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Custom Permissions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{if( \seqsplit{System.FeatureManagement.checkPermission(} \newline 'ACustPerm' ) == true ) \{ ... \newline \newline \newline \textless{}apex:pageBlock rendered="\{!\$Permission.ACustPerm\}" \textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.6 cm} x{6.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Custom Settings Methods}} \tn % Row 0 \SetRowColor{LightBackground} List: & List\textless{}Games\_\_c\textgreater{} gamesListCustomSetting = \seqsplit{Games\_\_c.getAll().values();} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & gamesListCustomSetting{[}0{]}.GameType\_\_c; // getAll() returns a map \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} & Games\_\_c aSingleCustomSetting = Games\_\_c.getValues( 'Pac Man' ); // same as getInstance() \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{Hierarchy:} & Support\_\_c \seqsplit{supportHierarchyCustomSetting} = \seqsplit{Support\_\_c.getInstance(} profileID ); \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} & Support\_\_c \seqsplit{supportHierarchyCustomSetting} = \seqsplit{Support\_\_c.getOrgDefaults();} \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} & Support\_\_c \seqsplit{supportHierarchyCustomSetting} = Support\_\_c.getValues( userID ); \tn % Row Count 17 (+ 3) % Row 6 \SetRowColor{LightBackground} & // getValues doesn't merge the non-overriden values from the hierarchy \tn % Row Count 20 (+ 3) % Row 7 \SetRowColor{white} & same as \{!\$Setup.Support\_\_c.Config\_Field\_\_c\} \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Date/DateTime Formats and Examples}} \tn % Row 0 \SetRowColor{LightBackground} myDate.format() & format() and parse() use the current user locale \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{myDate = Date.parse( '12/27/2009' );} \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} myDate = Date.valueOf( '2009-12-27 23:46:00' ); & uses standard datetime format \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{myDate.toStartMonth()} \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{myDate.toStartWeek()} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 9 (+ 0) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{dt.format()} \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} dt.format( 'YYYY-MM-dd hh:mm:ss.SSS a' ) & 2019-06-30 02:06:30.720 PM \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} dt.format( 'EEEEE MMMMM dd, YYYY HH:mmZ' ) & Sunday June 30, 2019 14:06+0600 \tn % Row Count 15 (+ 3) % Row 9 \SetRowColor{white} & z is timezone (CST), w is week in year, W is week in month, D is day in year, u is day number in week (1=Monday) \tn % Row Count 21 (+ 6) % Row 10 \SetRowColor{LightBackground} dt.getTime() & number of milisseconds since Jan 1, 1970 00:00 \tn % Row Count 24 (+ 3) % Row 11 \SetRowColor{white} dt = DateTime.parse( '10/14/2011 11:46 PM' ); & uses current user locale \tn % Row Count 27 (+ 3) % Row 12 \SetRowColor{LightBackground} dt = Datetime.valueOf( '2011-10-14 23:46:00' ); & uses standard datetime format \tn % Row Count 30 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Examples Using Named Credentials}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{HttpRequest req = new HttpRequest(); \newline req.setEndpoint('callout:MyNamedCredential/somePath'); \newline \newline req.setHeader('X-Username', '\{!\$Credential.UserName\}'); \newline req.setHeader('X-Password', '\{!\$Credential.Password\}'); \newline req.setBody( \newline 'UserName:\{! HTMLENCODE(\$Credential.Username)\}' ); \newline req.setHeader( 'Authorization' \newline , 'OAuth \{!\$Credential.OAuthToken\}' ); \newline \newline \textless{}!-{}- values: Basic, Bearer or null -{}-\textgreater{} \newline \{!\$Credential.AuthorizationMethod\} \newline \newline \textless{}!-{}- values: Base-64 encoded username and password, \newline OAuth token or null -{}-\textgreater{} \newline \{!\$Credential.AuthorizationHeaderValue\} \newline \newline \{!\$Credential.OAuthConsumerKey\} \newline \newline // usually Basic authentication goes like this instead \newline of \{!\$Credential.AuthorizationHeaderValue\} \newline Blob headerValue = Blob.valueOf( \newline username + ':' + password ); \newline String authorizationHeader = 'BASIC ' \newline + \seqsplit{EncodingUtil.base64Encode(} headerValue ); \newline req.setHeader( 'Authorization', authorizationHeader );} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Test Web Service Callouts}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{global class myWebServiceMockImpl \newline implements WebServiceMock \{ \newline global void doInvoke( Object stub \newline , Object request \newline , Map\textless{}String, Object\textgreater{} response \newline , String endpoint, String soapAction \newline , String requestName \newline , String responseNS \newline , String responseName \newline , String responseType ) \{ \newline // create/populate response element and add it \newline // to the response parameter \newline // this assumes responseElement type is \newline // a WSDL-generated class \newline response.put( 'response\_x', responseElement ); \newline \newline Test.setMock( WebServiceMock.class \newline , new myWebServiceMockImpl() ); \newline // in the test class \newline \newline global class myHttpCalloutMockImpl \newline implements HttpCalloutMock \{ \newline global HTTPResponse respond( HTTPRequest req ) \{ \newline // create fake response, set HTTPResponse \newline // values, and return it \newline \newline Test.setMock( HttpCalloutMock.class \newline , new myHttpCalloutMockImpl() );} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Email Messaging}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{Messaging.SingleEmailMessage} msg = \newline new \seqsplit{Messaging.SingleEmailMessage();} \newline msg.toAddresses = new String{[}{]} \{ \newline ...up to 100 contact/lead/user ids... \}; \newline msg.setTargetObjectId( ...single cont/lead/user id... ); \newline msg.subject = 'Test msg'; \newline msg.plainTextBody = 'Test body.'; \newline Messaging.SingleEmailMessage{[}{]} msgList = \newline new List\textless{}Messaging.SingleEmailMessage\textgreater{} \{ msg \}; \newline Messaging.SendEmailResult{[}{]} results = \newline Messaging.sendEmail( msgList ); \newline \newline // check results{[} 0 {]}.success \newline // and results{[} 0 {]}.errors{[} 0 {]}.message) \newline \newline Messaging.MassEmailMessage msg = \newline new \seqsplit{Messaging.MassEmailMessage();} \newline msg.setTargetObjectIds( \newline ...up to 250 cont/lead/user ids in List\textless{}ID\textgreater{}... );} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{String Concatenation}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{List\textless{}String\textgreater{} soqlList = new List\textless{}String\textgreater{} \{ \newline 'SELECT ID, ', fieldList, ' FROM ...' \}; \newline \newline String soql = String.join( soqlList, '' );} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{String Parsing with Regex}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{String template = '\{0\} was last updated \{1\}'; \newline List\textless{}Object\textgreater{} parameters = new List\textless{}Object\textgreater{} \{ \newline 'Universal Containers' \newline , DateTime.newInstance( 2018, 11, 15 ) \}; \newline String formatted = String.format( template, paramtrs ); \newline \newline Pattern ptn = Pattern.compile( \newline '...some regex with capturing groups...' ); \newline Matcher mtr = ptn.matcher( '...input string...' ); \newline for( Integer i = 0; i \textless{} mtr.groupCount(); i++ ) \{ \newline // NOTE: group 0 is the entire expression \newline String extract = mtr.group( i ); \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{SOQL Date Functions and Formats}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{CALENDAR\_YEAR(), CALENDAR\_MONTH() \newline DAY\_IN\_YEAR() Feb 1st = 32 \newline DAY\_IN\_MONTH() \newline DAY\_IN\_WEEK() Sunday = 1 \newline WEEK\_IN\_MONTH() \newline WEEK\_IN\_YEAR() \newline YESTERDAY, TODAY, TOMORROW \newline LAST\_X, THIS\_X, NEXT\_X \newline where X can be (where it makes sense): \newline YEAR, N\_YEARS:n \newline FISCAL\_YEAR, N\_FISCAL\_​YEARS:n \newline FISCAL\_QUARTER, N\_FISCAL\_​QUARTERS:n \newline QUARTER, N\_QUARTERS:n \newline MONTH, N\_MONTHS:n \newline 90\_DAYS, N\_DAYS:n \newline WEEK, N\_WEEKS\_:n} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Schema Functions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Record Creation with nulls or with default values \newline and record ids \newline \newline Map\textless{}String, Schema.SObjectType\textgreater{} sObjTypeMap = \newline \seqsplit{Schema.getGlobalDescribe();} \newline Schema.SObjectType targetType = \newline sObjTypeMap.get( typeName ); \newline SObject sobj = targetType.newSObject(); \newline SObject sobj = targetType.newSObject( \newline aRecordTypeId, loadDefaultsFlag ); \newline \newline Schema.SObjectType targetType = myObj\_\_c.SObjectType; \newline \newline myObj\_\_c m = new myObj\_\_c(); \newline Schema.SObjectType targetType = m.getSObjectType(); \newline \newline ID Prefix \newline Schema.DescribeSObjectResult dscObj = descrResult{[} 0 {]}; \newline String objPrefix = dscObj.getKeyPrefix();} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Schema Functions - Field Details}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{FieldSets \newline Map\textless{}String, Schema.FieldSet\textgreater{} fsMap = \newline \seqsplit{dscObj.fieldSets.getMap();} \newline \newline Fields \newline Schema.DescribeFieldResult dfr = \newline \seqsplit{dscObj.fields.myField\_\_c;} \newline \newline Schema.SObjectField fieldToken = \newline \seqsplit{mySObj\_\_c.myField\_\_c;} \newline Schema.DescribeFieldResult dfr = \newline \seqsplit{fieldToken.getDescribe();} \newline \newline Map\textless{}String, Schema.SObjectField\textgreater{} fieldMap = \newline \seqsplit{Schema.SObjectType.mySObj\_\_c.fields.getMap();} \newline \newline Field Details \newline dfr.getLabel(), getName(), getDefaultValue(), \newline getType(), getInlineHelpText(), ... \newline \newline Picklist Values \newline List\textless{}Schema.PicklistEntry\textgreater{} pleList = \newline dfr.getPicklistValues(); \newline // pleList{[} 0 {]}.getLabel(), getValue(), ...} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Schema Functions - Record Types}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Schema.DescribeSObjectResult{[}{]} descrResult = \newline Schema.describeSObjects( new String{[}{]} \{ \newline 'Account','Contact' \} ); \newline Schema.DescribeSObjectResult dscObj = descrResult{[} 0 {]}; \newline List\textless{}Schema.RecordTypeInfo\textgreater{} recTypeList = \newline \seqsplit{dscObj.getRecordTypeInfos();} \newline Map\textless{}Id, Schema.RecordTypeInfo\textgreater{} rTypeByIdMap = \newline \seqsplit{dscObj.getRecordTypeInfosById();} \newline Map\textless{}String, Schema.RecordTypeInfo\textgreater{} rTypeMap = \newline \seqsplit{dscObj.getRecordTypeInfosByDeveloperName();} \newline // ...getRecordTypeId() getName() getDeveloperName()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Sanitizing Input}} \tn % Row 0 \SetRowColor{LightBackground} HTMLENCODE() & replaces HTML reserved characters, \textgreater{} becomes \> \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} JSENCODE() & prepends escape on JS characters, ' becomes \textbackslash{}' \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{JSINHTMLENCODE()} & same as JSENCODE(HTMLENCODE(()) \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} URLENCODE() & replaces illegal characters in URLs, spaces becomes \%20, ? becomes \%21 \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{myString.stripHtmlTags();} & removes tags from string \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{FieldSet Examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Map\textless{}String, Schema.FieldSet\textgreater{} fsMap = \newline \seqsplit{Schema.SObjectType.Account.fieldSets.getMap();} \newline Schema.DescribeSObjectResult d = \newline \seqsplit{Account.sObjectType.getDescribe();} \newline Map\textless{}String, Schema.FieldSet\textgreater{} fsMap = \newline d.fieldSets.getMap(); \newline \newline Schema.FieldSet fs2 = \seqsplit{Schema.SObjectType.Account} \newline \seqsplit{.fieldSets.myFieldSetName;} \newline \newline public List\textless{}Schema.FieldSetMember\textgreater{} fldList \{ get; set; \} \newline fldList = \seqsplit{SObjectType.mySObject.FieldSets} \newline \seqsplit{.myFieldSetName.getFields();} \newline \newline // fieldSet methods: getName() getLabel() \newline \newline \textless{}apex:pageBlockTable value="\{!productLineItems\}" \newline var="qli" \textgreater{} \newline \newline \textless{}apex:repeat value="\{!\$ObjectType.QuoteLineItem \newline .FieldSets.Sales\_Forecast\_Page\_Detail\_Fields\}" \newline var="f" \textgreater{} \newline \textless{}apex:column value="\{!qli{[} f {]}\}" \newline rendered="\{! FIND( f, editableFieldList ) \textless{}= 0 \}" /\textgreater{} \newline \newline \textless{}apex:column \newline rendered="\{! FIND( f, editableFieldList ) \textgreater{} 0 \}" \textgreater{} \newline \textless{}apex:facet name="header"\textgreater{}\{!f.label\} \newline \textless{}/apex:facet\textgreater{} \newline \textless{}apex:inputField value="\{!qli{[} f {]}\}" /\textgreater{} \newline \textless{}/apex:column\textgreater{} \newline \textless{}/apex:repeat\textgreater{} \newline ...} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{VisualForce TabPanel (alternative 1)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:tabPanel id="theTabPanel" switchType="server" value="\{!varSelectedTab\}" \textgreater{}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}apex:tab id="tabOne" label="One" name="name1" \textgreater{}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~...content for tab one...} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 6 (+ 0) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// in the controller...} \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{public String varSelectedTab \{} \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~get;} \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~set \{} \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~// save data from tab, stop tab change if failed saving} \tn % Row Count 13 (+ 3) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~if( varSelectedTab == null || saveData() == true ) \{} \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{~~~~~~~~~~~~varSelectedTab} = value;} \tn % Row Count 17 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~\}} \tn % Row Count 18 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~\}} \tn % Row Count 19 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\}} \tn % Row Count 20 (+ 1) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// Apex to change the active tab: varSelectedTab = "name1";} \tn % Row Count 22 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{varSelectedTab = 'name1';} \tn % Row Count 23 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{VisualForce TabPanel (alternative 2)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:actionFunction name="changedTabJS" action="\{!changedTab\}" \seqsplit{reRender="divContainingTabPanel},errorMsgPanel" \textgreater{}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}apex:param name="tabName" assignTo="\{!clickedTab\}" value="" /\textgreater{}} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}/apex:actionFunction\textgreater{}} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 6 (+ 0) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:tabPanel id="theTabPanel" switchType="client" selectedTab="name1" value="\{!varSelectedTab\}" \textgreater{}} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}apex:tab id="tabOne" label="One" name="name1" \seqsplit{onTabEnter="changedTabJS(} 'name1' );return false;" \textgreater{}} \tn % Row Count 11 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~...content for tab one...} \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 13 (+ 0) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// in the controller...} \tn % Row Count 14 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{public PageReference changedTab() \{} \tn % Row Count 15 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~saveData();} \tn % Row Count 16 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~if( \seqsplit{ApexPages.getMessages().size()} \textless{}= 0 ) \{} \tn % Row Count 18 (+ 2) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~// allow tab to change if no errors} \tn % Row Count 20 (+ 2) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~~~~~varSelectedTab = clickedTab;} \tn % Row Count 22 (+ 2) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~\}} \tn % Row Count 23 (+ 1) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~} \tn % Row Count 24 (+ 1) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~return null;} \tn % Row Count 25 (+ 1) % Row 17 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\}} \tn % Row Count 26 (+ 1) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{// Apex to change the active tab:} \tn % Row Count 27 (+ 1) % Row 19 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{varSelectedTab = "name1";} \tn % Row Count 28 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{VisualForce apex:CommandButton with parameters}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:commandButton value=... action=... \newline \seqsplit{reRender="someDummyDivOrPageBlock"} \textgreater{} \newline \textless{}apex:param name=... value="\{!...\}" \newline assignTo="\{!...\}" /\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{VisualForce apex:ActionSupport with parameters}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:inputField value=... \newline \textless{}apex:actionSupport event="onchange" \newline action="\{!...\}" reRender=... \textgreater{} \newline \textless{}apex:param name=... value="\{!...\}" \newline assignTo="\{!...\}" /\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{VisualForce Link/Format with Param Examples}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:outputLink value="http://google.com/search"\textgreater{}Search Google} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}apex:param name="q" value="\{!contact.name\}"/\textgreater{}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}!-{}- this will append the q parameter to the URL -{}-\textgreater{}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 6 (+ 0) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:outputText value="Formatted time now: \{0, date, yyyy.MM.dd G 'at' HH:mm:ss z\}"\textgreater{}} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}apex:param value="\{! NOW() \}" /\textgreater{}} \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 10 (+ 0) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:outputText value="\{0, number, \#\#\#,\#\#\#,\#\#0.00\}"\textgreater{}} \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{~~~~\textless{}apex:param value="\{!Account.AnnualRevenue\}" /\textgreater{}} \tn % Row Count 14 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 14 (+ 0) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:outputText value="\{0, number, currency\}"\textgreater{}} \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Custom HTML Attributes in VisualForce}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:outputPanel layout="block" html-data-role="panel" html-data-id="menu"\textgreater{}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{becomes \textless{}div data-id="menu" data-role="panel"\textgreater{}} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Blank Space}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{. \newline . \newline .} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Global Variables - URL Examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\$Site.BaseUrl path prefix not ending with a / \newline \newline \{!\$Action{[} 'mySObject\_\_c' {]}.New\} \newline \newline \{!URLFOR(\$Action.mySObject\_\_c.New)\} \newline \newline URLFOR(\$Action.Measurement\_\_c.New, null \newline , {[}'CF00N3h00000HjxMj\_lkid'=recordID \newline ,'CF00N3h00000HjxMj'=theRecord.Name \newline ,'retURL'=\$CurrentPage.URL \newline ,'saveURL'='/apex/EditMeasurements?id='+recordID \newline ,'cancelURL'='/apex/EditMeasurements?id='+recordID{]}) \newline some valid values: Clone, New, Edit, Delete \newline , List, Merge, Tab, View, Attachment.Download \newline \newline The above corresponds to \newline return new \seqsplit{ApexPages.StandardController(} \newline theRecord ).view(); \newline \newline \{!URLFOR(\$Asset.SLDS \newline , \seqsplit{'assets/images/profile\_avatar\_96}.png')\} \newline reference to icons from SLDS \newline \seqsplit{https://lightningdesignsystem}.com/icons/ \newline \newline \newline \{!\$Resource.TestImage\} \newline \{!URLFOR( \$Resource.TestZip, 'images/Bluehills.jpg' )} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Global Variables - Field Examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}apex:repeat var="f" \newline value="\{!\$ObjectType.Account.FieldSets.myFieldSet\}"\textgreater{} \newline \textless{}apex:outputText value="\{!f\}" /\textgreater{} \newline \newline same as Schema.FieldSet fs = Schema.SObjectType \newline \seqsplit{.Account.fieldSets.getMap().get('myFieldSet')} \newline or \newline Schema.FieldSet fs = \seqsplit{Schema.SObjectType.Account} \newline .fieldSets.myFieldSet; \newline \newline \{!\$ObjectType.myObj\_\_c.keyPrefix\} \newline same as \seqsplit{Schema.DescribeSObjectResult} objDescr = \newline \seqsplit{Account.sObjectType.getDescribe();} \newline objDescr.getKeyPrefix() \newline \newline other options are: label, labelPlural, name, \newline accessible, createable, custom, deletable, \newline mergeable, queryable, searchable, undeletable, \newline updateable, ... \newline \newline \{!\$ObjectType.myObj\_\_c.Fields.aField\_\_c\} \newline \newline \{!\$ObjectType{[} 'myObj\_\_c' {]}.fields{[} 'aField\_\_c' {]}.Label\} \newline \{!\$ObjectType.myObj\_\_c.Fields.aField\_\_c.Label\} \newline \newline same as \seqsplit{Schema.DescribeFieldResult} dfr = \newline \seqsplit{Schema.SObjectType.myObj\_\_c.fields.aField\_\_c;} \newline dfr.getLabel() \newline \newline other options are: inlineHelpText, length, \newline picklistValues, precision, scale, type, acessible, \newline calculated, ...} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Global Variables - Miscelaneous Examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\$Api.Session\_ID \newline same as UserInfo.getSessionId() \newline (this ID changes in VF and Lightning) \newline and the formula function GETSESSIONID() \newline \newline document.getElementById( \newline "\{!\$Component.theForm.theBlock.theSection \newline .theSectionItem.theField\}" ) \newline \newline \$CurrentPage.parameters.paramName \newline same as \seqsplit{ApexPages.currentPage().getParameters()} \newline .get( 'paramName' ) \newline \newline \$Setup.App\_Prefs\_\_c.Show\_Help\_Content\_\_c \newline gets value from hierarchy custom settings \newline \newline \{!\$User.UITheme == 'Theme2'\} \newline Theme3 = Classic, \newline Theme4d = lightning, \newline Theme4t = mobile app, \newline Theme4u = lightning console} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}