<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Aditya Naag Topalli — Blog</title>
  <subtitle>Notes on developer advocacy, Salesforce, and building with emerging tech.</subtitle>
  <link href="https://adityanaag.com/feed.xml" rel="self" />
  <link href="https://adityanaag.com/" />
  <updated>2018-10-02T00:00:00Z</updated>
  <id>https://adityanaag.com/</id>
  <author>
    <name>Aditya Naag Topalli</name>
  </author>
  <entry>
    <title>Make PDF Files Download and not Open in Browser</title>
    <link href="https://adityanaag.com/blog/make-pdf-files-download-and-not-open-in-browser/" />
    <updated>2015-03-04T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/make-pdf-files-download-and-not-open-in-browser/</id>
    <content type="html">&lt;p&gt;Most browsers have an inbuilt capability to execute certain types of files. When these types of files encountered in a URL, typically when you click on a PDF Document or Attachment in Salesforce, the browser executes them and displays them in the browser itself, without triggering a “Save As” popup.&lt;/p&gt;
&lt;p&gt;For Example, &lt;code&gt;&amp;lt;Instance&amp;gt;/servlet/servlet.FileDownload?file=&amp;lt;DocumentID&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;However, in Salesforce, you can choose the default behavior of such kind of files.&lt;/p&gt;
&lt;p&gt;From the Setup Menu, Navigate to Security Controls -&amp;gt; File Upload and Download Security.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/fileDownload.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;This page lists the type of files  and their Default Download behavior. There are 3 options available :&lt;/p&gt;
&lt;p&gt;a) Download (Recommended): The file is always downloaded.&lt;/p&gt;
&lt;p&gt;b) Execute in Browser: The file is displayed and executed automatically when accessed in a browser or through an HTTP request.&lt;/p&gt;
&lt;p&gt;c) Hybrid:  The file uses the default browser execution behavior but Salesforce CRM and Chatter files are downloaded.&lt;/p&gt;
&lt;p&gt;Official Documentation at &lt;a href=&quot;https://help.salesforce.com/apex/HTViewHelpDoc?id=admin_files_type_security.htm&quot;&gt;https://help.salesforce.com/apex/HTViewHelpDoc?id=admin_files_type_security.htm&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Execute Javascript from Formula field</title>
    <link href="https://adityanaag.com/blog/execute-javascript-from-formula-field/" />
    <updated>2015-03-06T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/execute-javascript-from-formula-field/</id>
    <content type="html">&lt;p&gt;Yes, formula fields can be used to execute javascript code on click. For this, we make use of the HYPERLINK Function.&lt;/p&gt;
&lt;p&gt;The syntax for it is:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;HYPERLINK&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;javascript:&amp;lt;your javascript code&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;TEXT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To reload the page:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;HYPERLINK&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;javascript:window.location.reload()&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;TEXT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To open a SubTab:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;HYPERLINK&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;javascript:srcUp(&#39;URL&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;TEXT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;HYPERLINK&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;javascript:sforce.console.getEnclosingPrimaryTabId(function(result){sforce.console.openSubtab(result.id, &#39;&#39;, true, &#39;&#39; , null);})&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DEPRECATED&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;FOR&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;IN&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;STANDARD&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;SERVICE&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;CONSOLE&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;USE&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;SRCUP&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;INSTEAD&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Go ahead and knock yourself out!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>File Preview in Visualforce</title>
    <link href="https://adityanaag.com/blog/file-preview-in-visualforce/" />
    <updated>2015-03-10T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/file-preview-in-visualforce/</id>
    <content type="html">&lt;p&gt;Ever notice how cool, the preview functionality in Salesforce Chatter is? Well, you can reuse the same component that Salesforce does.&lt;/p&gt;
&lt;p&gt;Chatter uses a Shockwave Plugin to preview files. We can make use of the same plugin using the &lt;strong&gt;&lt;embed&gt;&lt;/strong&gt; tag in VisualForce.&lt;/p&gt;
&lt;p&gt;Here’s the tag:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;embed&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/_swf/190003/sfc/flex/DocViewer.swf&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;flashvars&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;shepherd_prefix=/sfc/servlet.shepherd&amp;amp;v=**&amp;lt;DocumentVersionId&gt;**&amp;amp;mode=chatter_bubble&amp;amp;in_tests=false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;100%&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;100%&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;align&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;middle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;renditionLarge&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;quality&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;high&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;bgcolor&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#f3f3f3&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;renditionLarge&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;allowscriptaccess&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;always&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;allowfullscreen&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;pluginspage&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://www.adobe.com/go/getflashplayer&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;wmode&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;opaque&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;application/x-shockwave-flash&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The only thing you need to add to the link is the Document Version ID. (Not the Document ID)&lt;/p&gt;
&lt;p&gt;You get the Version ID from the &lt;code&gt;RelatedRecordId&lt;/code&gt; field of a &lt;code&gt;FeedItem&lt;/code&gt;, or you can query the &lt;code&gt;ContentVersion&lt;/code&gt; Object.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Thumbnails in VisualForce</title>
    <link href="https://adityanaag.com/blog/thumbnails-in-visualforce/" />
    <updated>2015-03-12T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/thumbnails-in-visualforce/</id>
    <content type="html">&lt;p&gt;Most of the files uploaded to Chatter have a thumbnail next to them which shows the snapshot of the first page of the file.&lt;/p&gt;
&lt;p&gt;Well, you too can generate the thumbnail for the files you upload and display those in your VisualForce Pages.&lt;/p&gt;
&lt;p&gt;Thumbnails are dynamically generated whenever you access the below URL:&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;sfc&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;servlet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shepherd&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;version&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;renditionDownload&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;rendition&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;THUMB120BY90&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;versionId&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;VersionId&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;operationContext&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;CHATTER&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This link is delivered through either the &lt;a href=&quot;http://content.force.com&quot;&gt;content.force.com&lt;/a&gt; domain - &lt;a href=&quot;https://c&quot;&gt;https://c&lt;/a&gt;.&lt;Instance&gt;.content.force.com/ or the Community URL - http://&lt;DomainName&gt;.force.com/&lt;CommunityName&gt;&lt;/CommunityName&gt;&lt;/DomainName&gt;&lt;/Instance&gt;&lt;/p&gt;
&lt;p&gt;This URL has 2 important Parameters:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rendition:&lt;/strong&gt; Specifies the Size of the Thumbnail to be generated.&lt;/p&gt;
&lt;p&gt;Available Sizes: THUMB120BY90, THUMB240BY180, THUMB720BY480 &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Version ID :&lt;/strong&gt; The Content Version ID of the Document. This is available from the RelatedRecordId Field of a FeedItem or by querying the ContentVersion Object.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/thumbnails-vf.PNG&quot; alt=&quot;Thumbnails in Visualforce&quot; title=&quot;Thumbnail in Visualforce&quot;&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Getting Started with Lightning!</title>
    <link href="https://adityanaag.com/blog/getting-started-with-lightning/" />
    <updated>2015-03-15T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/getting-started-with-lightning/</id>
    <content type="html">&lt;p&gt;Here are a few points from the Meetup organized as a part of Salesforce1 Lightning Developer Week.&lt;/p&gt;
&lt;p&gt;Salesforce1 Lightning is an all new Component Based Framework built on the Aura Platform which significantly reduces development and maintenance time.&lt;/p&gt;
&lt;p&gt;It provides us with a set of point and click tools using which we can build and deploy apps at Lightning Speed.&lt;/p&gt;
&lt;p&gt;The 4 Major Components of Lightning are:&lt;/p&gt;
&lt;h4 id=&quot;1.-lightning-connect-%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://adityanaag.com/blog/getting-started-with-lightning/#1.-lightning-connect-%3A&quot;&gt;1. Lightning Connect :&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Lets you connect to any external data source that supports oData format and fetch the data from it in real time with point and click simplicity.&lt;br&gt;
All the data that is fetched is available in Read Only Mode. None of the data is actually stored or cached in Salesforce.&lt;br&gt;
The data tat is fetched from an external source is mapped to something called an External Object, whose API Name is suffixed by __x. &lt;br&gt;
Some key differences between an External Object and a Custom/Standard Object include No Triggers or Validation Rules - as the data is not actually stored in Salesforce, none of these would be applicable.&lt;/p&gt;
&lt;p&gt;For a comprehensive hands-on tutorial, here’s the link&lt;br&gt;
&lt;a href=&quot;http://bit.ly/lightning-connect-tutorial&quot;&gt;http://bit.ly/lightning-connect-tutorial&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&quot;2.-lightning-process-builder&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://adityanaag.com/blog/getting-started-with-lightning/#2.-lightning-process-builder&quot;&gt;2. Lightning Process Builder&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Stating simply, it is a highly advanced Visual Workflow. It helps you quickly build and automate a business process with point and click operations.&lt;br&gt;
Its capabilities exceed that of a normal workflow,where Process builder allows you to additionally &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create Unrelated Records - thus eliminating the need to write simple triggers&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Post to Chatter&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Send record for Approval and many more.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The process runs completely in the background without the need of any UI(A key difference between this and a Visual Workflow) and can be configured to start executing whenever a new Record is inserted, Updated with optional filter criteria.&lt;/p&gt;
&lt;p&gt;For a comprehensive hands-on tutorial, here’s the link&lt;br&gt;
&lt;a href=&quot;http://bit.ly/process_lightning_tutorial&quot;&gt;http://bit.ly/process_lightning_tutorial&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&quot;3.-lightning-components&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://adityanaag.com/blog/getting-started-with-lightning/#3.-lightning-components&quot;&gt;3. Lightning Components&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;It is a UI Framework which helps you build responsive and dynamic Applications using the Aura Framework.&lt;br&gt;
The key idea behind this is to build reusable components each with their own UI, Styles and Business logic. Each of these components can then be put together to build an App in no time.&lt;br&gt;
Salesforce provides you with a set of standard components which you can use while building your app .you can create your own custom components or download components from AppExchange.&lt;/p&gt;
&lt;p&gt;For a comprehensive hands-on tutorial, here’s the link&lt;br&gt;
&lt;a href=&quot;http://bit.ly/lightning_components_tutorial&quot;&gt;http://bit.ly/lightning-components-tutorial&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&quot;4.-lightning-app-builder&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://adityanaag.com/blog/getting-started-with-lightning/#4.-lightning-app-builder&quot;&gt;4. Lightning App Builder&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;A drag and drop interface which allows you to build apps using components. It allows you to design apps for every screen size using one canvas.&lt;/p&gt;
&lt;p&gt;For a comprehensive hands-on tutorial, here’s the link&lt;br&gt;
&lt;a href=&quot;http://bit.ly/app_builder_lightning&quot;&gt;http://bit.ly/app_builder_lightning&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;App Builder is not enabled by default in DE orgs and must be requested from Salesforce.&lt;/p&gt;
&lt;p&gt;However, Register from the below link and try Lightning App Builder for Free.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://bit.ly/lightning-org&quot;&gt;http://bit.ly/lightning-org&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Predictable Iteration Order for Maps and Sets</title>
    <link href="https://adityanaag.com/blog/predictable-iteration-order-for-maps-and-sets/" />
    <updated>2015-04-01T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/predictable-iteration-order-for-maps-and-sets/</id>
    <content type="html">&lt;p&gt;Salesforce on 1st April has notified a change to the iteration order for unordered collections (maps and sets). &lt;/p&gt;
&lt;p&gt;A map is a collection of key-value pairs where each unique key maps to a single value.&lt;/p&gt;
&lt;p&gt;A set is a collection of unique elements.&lt;/p&gt;
&lt;p&gt;It is changing the implementation for unordered collections to make the order of elements in those collections deterministic.&lt;/p&gt;
&lt;p&gt;With this update, &lt;strong&gt;“The order of elements in maps and sets will be the same every time your code is run again.”&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;On March 24, 2015, this change was released as a critical update in the application, which gives you control over testing and activating this change in your org. &lt;/p&gt;
&lt;p&gt;When you activate the critical update called “Predictable Iteration Order for Apex Unordered Collections” in Spring &#39;15, the order of returned results is no longer arbitrary. The order of elements is deterministic - the order is the same every time you run the same code.&lt;/p&gt;
&lt;p&gt;To make sure your code works perfectly even after the update:&lt;/p&gt;
&lt;p&gt;Remove/Rewrite any Apex code that exercises order-dependent logic on unordered collections.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Parsing JSON the easy way using Apex</title>
    <link href="https://adityanaag.com/blog/parsing-json-the-easy-way-using-apex/" />
    <updated>2015-04-03T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/parsing-json-the-easy-way-using-apex/</id>
    <content type="html">&lt;p&gt;JSON is a lightweight data-interchange format. It is the most preferred way of transferring data over web.&lt;/p&gt;
&lt;p&gt;In Salesforce, this comes to most use when integrating with an external system.&lt;/p&gt;
&lt;p&gt;In most of the integrations, you typically use HTTP Callouts to the end points defined by various services, and the most common response format returned by these is JSON.&lt;/p&gt;
&lt;p&gt;Now, parsing this JSON would be very time consuming if not done in the right way. One way of doing this would be manually parsing the complete JSON using the &lt;strong&gt;JSONParser&lt;/strong&gt; method.&lt;/p&gt;
&lt;p&gt;But the easiest way of Parsing JSON would be to de-serialize it into an Object.&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; n &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;JSON&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deserialize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;JSON&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This one statement would completely de-serialize the JSON and store the values in the respective member variables of the class…&lt;/p&gt;
&lt;p&gt;For this, first we need to create a class or an Inner class, which would contain all the variables that are to be stored from the JSON.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The JSON2Apex is a very handy tool for this.&lt;/strong&gt; Goto &lt;a href=&quot;http://json2apex.herokuapp.com/&quot; title=&quot;JSON2Apex&quot;&gt;http://json2apex.herokuapp.com/&lt;/a&gt; and paste the JSON String in the space provided, and click on create Apex.&lt;/p&gt;
&lt;p&gt;This would give you a class with member variables from the JSON String. You can just use this class as is or you can paste it into your existing class like an inner class.&lt;/p&gt;
&lt;p&gt;You then use the JSON.de-serialize to parse the JSON.&lt;/p&gt;
&lt;p&gt;Below is the sample output from a callout to the Tooling API of Salesforce to query the Test Coverage (Read about &lt;a href=&quot;http://blog.adityanaag.com/23/Export+Apex+Code+Coverage+to+Excel&quot;&gt;Export Code Coverage to Excel&lt;/a&gt;)&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;size&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;141&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;totalSize&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;141&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;done&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;queryLocator&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;entityTypeName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ApexCodeCoverageAggregate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;records&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ApexCodeCoverageAggregate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715000000LxWDAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;715000000LxWDAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;ApexClassOrTrigger&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexClass/01p000000C8J2AAK&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;MyCustomClass1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesCovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesUncovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ApexCodeCoverageAggregate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715e0000000LxWEAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;710000000LxWEAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;ApexClassOrTrigger&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexClass/01pe0000000C8JCAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;MyCustomClass2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesCovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesUncovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This JSON would produce the below class when run through JSON2Apex Heroku App (&lt;a href=&quot;http://json2apex.herokuapp.com/&quot; title=&quot;JSON2Apex&quot;&gt;http://json2apex.herokuapp.com/&lt;/a&gt;)&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;JSON2Apex&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Attributes&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; type&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Records&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Attributes&lt;/span&gt; attributes&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; Id&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ApexClassOrTrigger&lt;/span&gt; ApexClassOrTrigger&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Integer&lt;/span&gt; NumLinesCovered&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Integer&lt;/span&gt; NumLinesUncovered&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ApexClassOrTrigger&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Attributes&lt;/span&gt; attributes&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; Name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Integer&lt;/span&gt; size&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Integer&lt;/span&gt; totalSize&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Boolean&lt;/span&gt; done&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Object&lt;/span&gt; queryLocator&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; entityTypeName&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt; records&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

	
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;JSON2Apex&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; json&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;JSON2Apex&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;JSON&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deserialize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; JSON2Apex&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can use this class, and deserialize the JSON by&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;JSON2Apex&lt;/span&gt; myClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; JSON2Apex&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;jsonString&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and you can then access the variables of this class by&lt;/p&gt;
&lt;p&gt;&lt;code&gt;myClass.done&lt;/code&gt;, &lt;code&gt;myClass.size&lt;/code&gt;, &lt;code&gt;myClass.records&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Note that separate inner classes are generated for each complex data type of the parsed JSON.&lt;br&gt;
For Example :&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;myClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;records&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ApexClassorTrigger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Name&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, ApexClassorTrigger is an inner class, with 2 variables : Name and Attributes which in turn has 2 variables Type and URL.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Export Apex Code Coverage to Excel</title>
    <link href="https://adityanaag.com/blog/export-apex-code-coverage-to-excel/" />
    <updated>2015-04-08T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/export-apex-code-coverage-to-excel/</id>
    <content type="html">&lt;p&gt;Tooling API proides a rich set of SOAP and REST interfaces that allow you to build custom development tools for &lt;a href=&quot;http://Force.com&quot;&gt;Force.com&lt;/a&gt; applications. We use one such interface for this - &lt;strong&gt;ApexCodeCoverageAggregate&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The query is just like a normal SOQL Query&lt;/p&gt;
&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;ApexClassorTrigger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;NumLinesCovered&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;NumLinesUncovered &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ApexCodeCoverageAggregate&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The execution of the query is different than the normal way. We have to make a HTTP Callout to the Tooling API Endpoint and pass this query as a URL parameter.&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;HttpRequest&lt;/span&gt; req &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HttpRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setHeader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Authorization&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Bearer &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; UserInfo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getSessionID&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setHeader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Content-Type&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;application/json&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setEndpoint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;URL&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getSalesforceBaseURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toExternalForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;/services/data/v33.0/tooling/query/?q=Select+id,ApexClassorTrigger.Name,NumLinesCovered,NumLinesUncovered+from+ApexCodeCoverageAggregate&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setMethod&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;GET&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;Http&lt;/span&gt; h &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Http&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;HttpResponse&lt;/span&gt; res &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; h&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The response would be the query result in JSON Format.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;size&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;141&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;totalSize&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;141&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;done&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;queryLocator&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;entityTypeName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ApexCodeCoverageAggregate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;records&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ApexCodeCoverageAggregate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715000000LxWDAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;715000000LxWDAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;ApexClassOrTrigger&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexClass/01p000000C8J2AAK&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;MyCustomClass1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesCovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesUncovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ApexCodeCoverageAggregate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715e0000000LxWEAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;710000000LxWEAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;ApexClassOrTrigger&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;attributes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/services/data/v33.0/tooling/sobjects/ApexClass/01pe0000000C8JCAA0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;MyCustomClass2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesCovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string-property property&quot;&gt;&quot;NumLinesUncovered&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then parse this JSON (Please refer &lt;a href=&quot;http://blog.adityanaag.com/22/Parsing+JSON+the+easy+way+using+Apex&quot;&gt;Parsing JSON the Easy way using Apex&lt;/a&gt;) and display it in a visual force page with any formatting of our choice.&lt;br&gt;
I have chosen to export this to an excel format for which we use the ContentType parameter of the &lt;a href=&quot;apex:page&quot;&gt;apex:page&lt;/a&gt; Tag&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;apex:&lt;/span&gt;page&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;controller&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ExportTestCoverage&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;contentType&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;application/vnd.ms-excel#Coverage.xls&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you’re done.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You need to add your current Salesforce Base URL to the Remote Site settings.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/adityanaag3/sfdc/tree/master/Export%20Test%20Coverage&quot;&gt;Click here&lt;/a&gt; to see Source files for this at GitHub&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>A whole new level of customization with Custom Buttons</title>
    <link href="https://adityanaag.com/blog/a-whole-new-level-of-customization-with-custom-buttons/" />
    <updated>2015-04-15T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/a-whole-new-level-of-customization-with-custom-buttons/</id>
    <content type="html">&lt;p&gt;One of the various behaviors of Custom Button is “Execute JavaScript”, with a content source of OnClick JavaScript.&lt;/p&gt;
&lt;p&gt;They can not only execute javascript Functions On Click, but you can make Javascript execute on page load too.&lt;/p&gt;
&lt;p&gt;The main use for this being complete control over every element in the object detail page without user clicking a button. We use jQuery for this.&lt;/p&gt;
&lt;p&gt;We begin by importing the required jQuery files.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Optionally you have to import connection.js and apex.js if you want to perform any operations using sforce.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;/soap/ajax/29.0/connection.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;/soap/ajax/29.0/apex.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Below is the jQuery code which hides a button and triggers the click of a button.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; j$ &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; jQuery&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;noConflict&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;j$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;j$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;input[name=**btn_Name**]&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;display&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;none&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;j$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;input[name=**btn_Name**]&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;trigger&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace &lt;strong&gt;btn_Name&lt;/strong&gt; with the name of the custom button you just created. Now, to make this code run on Page Load, we have to encode it into Base64, and add it to the REQUIRESCRIPT tag.&lt;/p&gt;
&lt;p&gt;Use the URL &lt;a href=&quot;http://rot47.net/base64encoder.html&quot;&gt;http://rot47.net/base64encoder.html&lt;/a&gt; to encode the jQuery code above. This will produce the below result.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;dmFyIGokID0galF1ZXJ5Lm5vQ29uZmxpY3QoKTsKaiQoZG9jdW1lbnQpLnJlYWR5KGZ1bmN0aW9uKCl7CmokKCJpbnB1dFtuYW1lPXVwbG9hZF9kb2N1bWVudF0iKS5jc3MoJ2Rpc3BsYXknLCdub25lJyk7CmokKCJpbnB1dFtuYW1lPXVwbG9hZF9kb2N1bWVudF0iKS50cmlnZ2VyKCdjbGljaycpOwp9KTs&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then use the below statement to embed this encoded content :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;data:application/javascript;base64,**ENCODED STRING**&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After this, you can write the Javascript code you want to execute on Load.&lt;/p&gt;
&lt;p&gt;The below example displays an alert on page load.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;REQUIRESCRIPT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;data:application/javascript;base64,dmFyIGokID0galF1ZXJ5Lm5vQ29uZmxpY3QoKTsKaiQoZG9jdW1lbnQpLnJlYWR5KGZ1bmN0aW9uKCl7CmokKCJpbnB1dFtuYW1lPXVwbG9hZF9kb2N1bWVudF0iKS5jc3MoJ2Rpc3BsYXknLCdub25lJyk7CmokKCJpbnB1dFtuYW1lPXVwbG9hZF9kb2N1bWVudF0iKS50cmlnZ2VyKCdjbGljaycpOwp9KTs=&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Hi {!$User.FirstName}&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since, the custom button is present in the HTML Content of the Object Detail page, you can use jQuery to select any element of the entire page and customize it.&lt;/p&gt;
&lt;p&gt;This will work in all places where SF Buttons are shown. So it won’t work in Salesforce1.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Translating text in a Visualforce Page</title>
    <link href="https://adityanaag.com/blog/translating-text-in-a-visualforce-page/" />
    <updated>2015-04-22T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/translating-text-in-a-visualforce-page/</id>
    <content type="html">&lt;p&gt;Translation workbench, when enabled, translates most standard stuff into the users language. But how do you get a visualforce page translated into a users language?&lt;/p&gt;
&lt;p&gt;You begin by replacing everything that is hardcoded in English, with Custom Labels, and refer those in the VF page by using the syntax&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;{!$Label.**LabelName**}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If any of the fields from an object are being referred, get their labels by using&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;{!$ObjectType.**&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ObjectName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;**.fields.**&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;FieldName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;**.label}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, you define the translations for each of the custom labels and the Standard/Custom fields or Picklist values. &lt;a href=&quot;https://help.salesforce.com/HTViewHelpDoc?id=cl_translate_edit.htm&amp;amp;language=en_US&quot;&gt;Click here&lt;/a&gt; to see how translations are given for Custom Labels. To show the VF page in the desired language, we use the language attribute of the apex:page tag.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;apex:&lt;/span&gt;page&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;doctype&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;HTML-5.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en_US&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each language is identified by a two-character language code, such as en, or a five-character locale code, such as en_AU which has to be given in the language attribute. &lt;a href=&quot;https://help.salesforce.com/apex/HTViewHelpDoc?id=faq_getstart_what_languages_does.htm&quot;&gt;Click here&lt;/a&gt; to see the list of available language codes.&lt;/p&gt;
&lt;p&gt;This langauge attribute can be dynamic based on User’s choice or based on the Language of the User.&lt;/p&gt;
&lt;p&gt;We use cookies to save the user’s choice of language when there is no user session, and we use the language field on the user object to save the user’s choice when the user is logged in.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;apex:&lt;/span&gt;page&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;doctype&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;HTML-5.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;{!userLangString}&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;UserInfo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getUserType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Guest&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; ApexPages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getCookies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;lang&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// lang is a custom cookie defined.&lt;/span&gt;
        &lt;span class=&quot;token class-name&quot;&gt;Cookie&lt;/span&gt; userLang &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ApexPages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getCookies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;lang&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt; userLangString &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; userLang&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;UserInfo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getUserType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Guest&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt; userlang &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token sql language-sql&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; LanguageLocaleKey &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; Id&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;:UserInfo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;getUserId&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LanguageLocaleKey&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To set the cookie for a user language, we set the cookie with the chosen language and refresh the page.&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PageReference&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;refreshPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;Cookie&lt;/span&gt; c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Cookie&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;lang&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; userLangString&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    ApexPages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setCookies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Cookie&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;PageReference&lt;/span&gt; p &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ApexPages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    p&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setRedirect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; p&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>Styling Visualforce PDFs</title>
    <link href="https://adityanaag.com/blog/styling-visualforce-pdfs/" />
    <updated>2016-02-01T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/styling-visualforce-pdfs/</id>
    <content type="html">&lt;p&gt;The below guide is useful in cases when you want to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add Header and Footer to PDF Documents&lt;/li&gt;
&lt;li&gt;Repeat Table Header on every page&lt;/li&gt;
&lt;li&gt;Adding border to tables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;First, to add styles to a Visualforce PDF, you need to have these 2 attributes in the &lt;a href=&quot;apex:page&quot;&gt;apex:page&lt;/a&gt; tag&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;renderAs=&quot;pdf&quot; applyBodyTag=&quot;false&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, you need to define your styles in the &lt;head&gt; tag&lt;/head&gt;&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;
		//All styles go here
	&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;To add Header and Footer&lt;/strong&gt;&lt;br&gt;
We use the @page rule of CSS for this. It lets you specify the format of the page like size, margin, header and footers.&lt;br&gt;
To define header and footer, we make use of the @top-center, @top-left, @top-right, @bottom-center etc attributes which define the position of the text in the header and footer sections of the page.&lt;/p&gt;
&lt;p&gt;Below is a sample&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;
	&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@page&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; A4&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@top-left&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token selector&quot;&gt;&quot;Company Name -&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;!merge_field&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&quot;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@top-right&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token selector&quot;&gt;&quot;Document Name -&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;!merge_field&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&quot;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@bottom-center&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Page &quot;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; of &quot;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;pages&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Repeat Table Header&lt;/strong&gt;&lt;br&gt;
To repeat the table header on every page incase the table spans across multiple pages, the table structure needs to be HTML5 compliant along with a few styles that we apply.&lt;br&gt;
The table structure should contain and tags&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;thead&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Header&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;thead&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tbody&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Text&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tbody&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fortunately, if you use the &lt;a href=&quot;apex:dataTable&quot;&gt;apex:dataTable&lt;/a&gt; tag, Salesforce automatically generates this for you.&lt;br&gt;
After which below is the style you have to apply to repeat table headers.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;-fs-table-paginate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; paginate&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;border-collapse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; collapse&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;border-spacing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Adding Border to Tables&lt;/strong&gt;&lt;br&gt;
Below is the basic CSS you have to apply to get a border on a table.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;td,th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px solid black&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;word-wrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; break-word&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After this, you might observe that there is a space between each column in the table, to avoid which you have to apply the below style&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;border-collapse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; collapse&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;border-spacing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The below style makes sure that a row isnt split across 2 pages if it has long text.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;table tr, table td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;page-break-inside&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; avoid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;word-wrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; break-word&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Additional Tip:&lt;/strong&gt; If you want to split content across multiple pages, use the below style on a placeholder tag like &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;page-break-after&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;always&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the final stylesheet&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;
          
          &lt;span class=&quot;token selector&quot;&gt;td,th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px solid black&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
			  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 7px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;word-wrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; break-word&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
          
          &lt;span class=&quot;token selector&quot;&gt;table tr, table td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;page-break-inside&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; avoid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
          
          &lt;span class=&quot;token selector&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;-fs-table-paginate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; paginate&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;border-collapse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; collapse&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;border-spacing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            
    &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>5 Useful Javascript Libraries</title>
    <link href="https://adityanaag.com/blog/5-useful-javascript-libraries/" />
    <updated>2016-02-20T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/5-useful-javascript-libraries/</id>
    <content type="html">&lt;p&gt;&lt;strong&gt;1. Datatable.js&lt;/strong&gt;&lt;br&gt;
Use this library to add advanced interaction like pagination, search controls to any HTML table. The pagination and search are completely on the client side and hence there is no delay in filtering or paging. This interaction can be applied on a prebuilt table or you can either fetch and display data in a table asynchronously. You have complete control over the DOM of the Table too.&lt;/p&gt;
&lt;p&gt;More information at &lt;a href=&quot;https://www.datatables.net/&quot;&gt;https://www.datatables.net/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For Ajax Operations: &lt;a href=&quot;https://www.datatables.net/examples/ajax/objects.html&quot;&gt;https://www.datatables.net/examples/ajax/objects.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Example Use case: Showing a table of Accounts with client side pagination and search. This search works on any column in the table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Select2.js&lt;/strong&gt;&lt;br&gt;
Use this library to create searchable drop downs with Autosuggest. Similar to Datatable.js, you can enable this on preloaded options in select boxes, or you can use Ajax to fetch the dropdown values.&lt;/p&gt;
&lt;p&gt;More information at &lt;a href=&quot;https://select2.github.io/examples.html&quot;&gt;https://select2.github.io/examples.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Example Use case: An Autosuggest and searchable drop down for City, ZipCode etc during registration process&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Typeahead.js&lt;/strong&gt;&lt;br&gt;
Very similar to Select2, but this operates on a Textbox instead of a Dropdown.&lt;/p&gt;
&lt;p&gt;More information at &lt;a href=&quot;https://twitter.github.io/typeahead.js/&quot;&gt;https://twitter.github.io/typeahead.js/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Example Use case: Product ID Text Box - Entering text in it would auto suggest existing productIds&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. SignaturePad.js&lt;/strong&gt;&lt;br&gt;
With more and more applications now mobile enabled, this library makes it easy to capture signatures from a mobile device. It gives a blank box where users can draw their signature.&lt;/p&gt;
&lt;p&gt;More information at &lt;a href=&quot;https://github.com/thomasjbradley/signature-pad/blob/gh-pages/documentation.md&quot;&gt;https://github.com/thomasjbradley/signature-pad/blob/gh-pages/documentation.md&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Example Use case: Capture the users signature and store it in a rich text area on the record.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. html2Canvas.js&lt;/strong&gt;&lt;br&gt;
This allows you to capture a screenshot of a page from the page itself. The output is an image which can be stored.&lt;/p&gt;
&lt;p&gt;More information at &lt;a href=&quot;https://html2canvas.hertzen.com/&quot;&gt;https://html2canvas.hertzen.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Example: For Error Logging - The end user can attach a screen shot of the page when reporting an error.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Salesforce Ohana Meet</title>
    <link href="https://adityanaag.com/blog/salesforce-ohana-meet/" />
    <updated>2018-01-15T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/salesforce-ohana-meet/</id>
    <content type="html">&lt;p&gt;A 2 day event, first of its kind, which brought together &amp;quot;S.I.&amp;quot;s (Systems Integrator - this is the first time I’ve heard this acronym by the way), Students and Community together under one common roof at Novotel Hyderabad, where I was representing Persistent Systems.&lt;/p&gt;
&lt;p&gt;This was my first time attending an event of this scale, where people had come from different places across the country and I had the pleasure of meeting in person, folks whom I have only heard of, or seen pictures of - which includes MVPs, DUG and WIT Leaders, Salesforce Dev Relationship team members headed by and including Jacob.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/the-one-with-mvps.jpg&quot; alt=&quot;The one with MVPs&quot; title=&quot;The one with MVPs&quot;&gt;&lt;br&gt;
Day 1 passed by very quickly, where each of the SIs were given like 5 minutes to talk about themselves, and how were they making a difference. It was inspiring to see the successful stints of many firms built from the ground up.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Fun fact: Jaipur is like Area 51 for Salesforce Startups.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It was then the turn of Colleges to talk about their Salesforce journey, and yes, I was very happy to see them welcoming new technologies like this to not just be a 2 day workshop, but to be a long-term learning program which helps students reap benefits out of this successful platform by building their careers on it. The credit of initiating this would of course go to the community leaders who were able to positively influence the colleges to take this up.&lt;/p&gt;
&lt;p&gt;Interweaved with these intros were some fun activities like ‘Connect &amp;amp; Disconnect’, ‘Elevator Pitch’ and most notably the panel discussions.&lt;/p&gt;
&lt;p&gt;A Community Leaders Panel Discussion which was enlightening to everyone alike. A lot of &amp;quot;good question&amp;quot;s asked and a WIT(Women in Technology) Panel Discussion where each of the panel members spoke about their experience so far, challenges they faced, risks they have taken in the process of getting to where they are now, and how they are working towards making life easier for new Trailblazers!&lt;/p&gt;
&lt;p&gt;Day 2 started with a tour of the mother ship a.k.a Salesforce Hyderabad Office. It was all what one would expect and more. Here is one thing that caught my eye at the very entrance - an array of Salesforce release logos since its inception.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/the-one-with-logos.jpg&quot; alt=&quot;Salesforce release logos&quot; title=&quot;The one with Salesforce release logos&quot;&gt;&lt;br&gt;
The remainder of the day was recruitment drives. I had a jog down memory lane when I looked at the students, all tensed, as they got their question papers, shortly after which they started bubbling the OMR away. The students were brave and didn’t shy away from getting on stage or from getting in front of a camera for media bytes, and not to mention smart… super duper smart. I was amazed at how quickly they had picked up Salesforce. The zeal and enthusiasm they had shown in completing a lot of badges and superbadges was definitely commendable. No wonder most of them got placed at multiple companies on the spot. The Reports and Dashboards superbadge sure was a hot favorite. The students have leveraged a great opportunity that was presented to them, and there is no turning back for them now.&lt;/p&gt;
&lt;p&gt;And finally, here is my Ohana, where everyone grows together and I am extermely proud and elated to be a part of it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/the-one-with-ohana.jpg&quot; alt=&quot;The one with Ohana&quot; title=&quot;The one with Ohana&quot;&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Use an Email Service Address as Organization Wide Address</title>
    <link href="https://adityanaag.com/blog/use-an-email-service-address-as-organization-wide-address/" />
    <updated>2018-03-03T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/use-an-email-service-address-as-organization-wide-address/</id>
    <content type="html">&lt;p&gt;Whenever you add an email address as an Organization Wide Address, Salesforce sends a verification email to that address with a link you have to click to verify that it is a real and valid address. Since the email service address you create doesn’t have an inbox where you can open and click the verification link sent, you will have to leverage the Inbound Email Handler Apex class which can process all the mails sent to it (including the verification email).&lt;/p&gt;
&lt;p&gt;Add the below code to your Inbound Email Handler, which creates a Document with the Name “Organization-Wide Address Verification” in the folder of your choice whenever the verification email gets sent to the service address. You can then open the document (which is a HTML document) and click the Verification Link to verify the address.&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isNotBlank&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;subject&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; email&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;subject&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;containsIgnoreCase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Verify your Salesforce Organization-Wide Address&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                
	&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Document&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; documents&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sObjectType&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getDescribe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isAccessible&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		documents &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token sql language-sql&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; id &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; Document &lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; Name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Organization-Wide Address Verification&#39;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;limit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token class-name&quot;&gt;Document&lt;/span&gt; d &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; documents&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Document&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; documents&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	d&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Blob&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;valueOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;htmlBody&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	d&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Organization-Wide Address Verification&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	d&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ContentType &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;text/html&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	d&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Type &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;html&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	d&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FolderId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token sql language-sql&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; id &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; Folder &lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Shared Documents&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Document&#39;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;limit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//You can choose any Document Folder you want&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sObjectType&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getDescribe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isCreateable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; Document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sObjectType&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getDescribe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isUpdateable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;upsert&lt;/span&gt; d&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
			
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>Preparing for Marketing Cloud Consultant Certification</title>
    <link href="https://adityanaag.com/blog/preparing-for-marketing-cloud-consultant-certification/" />
    <updated>2018-03-27T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/preparing-for-marketing-cloud-consultant-certification/</id>
    <content type="html">&lt;p&gt;No different from any other consultant exam, you will face a lot of scenario based questions where most of the times, you will have to choose more than 1 correct answer. The options can get quite confusing unless you are really strong in your understanding of various concepts in Marketing Cloud.&lt;/p&gt;
&lt;p&gt;Here are some links I have gone through which helped me crack the exam:&lt;/p&gt;
&lt;p&gt;First, no preparation starts without Trailhead, so make sure you go through all the modules related to Marketing Cloud. Importantly, the below ones.&lt;br&gt;
&lt;a href=&quot;https://trailhead.salesforce.com/modules/mr-email-marketing-strategies&quot;&gt;https://trailhead.salesforce.com/modules/mr-email-marketing-strategies&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;https://trailhead.salesforce.com/trails/personalize_customer_journeys_marketing_cloud&quot;&gt;https://trailhead.salesforce.com/trails/personalize_customer_journeys_marketing_cloud&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Next, these two study notes have everything you need to know, well explained and neatly organized into sections which align with the Official Study guide. Ensure you read through these in and out.&lt;br&gt;
&lt;a href=&quot;https://docs.google.com/document/d/14S1__RF9BX9IMofgrQcb0UrK2eu-dQ2l7_WJqjSzx4U/edit&quot;&gt;https://docs.google.com/document/d/14S1__RF9BX9IMofgrQcb0UrK2eu-dQ2l7_WJqjSzx4U/edit&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;https://docs.google.com/document/d/1-iTsnZafvDHR8_-1iLHCr1ZbiYvYOVKkBOjD781tHwY/edit&quot;&gt;https://docs.google.com/document/d/1-iTsnZafvDHR8_-1iLHCr1ZbiYvYOVKkBOjD781tHwY/edit&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And finally, here is a link to a brilliantly written 7-Part prep series by Anup Arora (again, aligned with the sections in the Official Study Guide) which can help you further strengthen your understanding on Marketing Cloud.&lt;br&gt;
&lt;a href=&quot;https://www.linkedin.com/in/anuparora/detail/recent-activity/posts/&quot;&gt;https://www.linkedin.com/in/anuparora/detail/recent-activity/posts/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All the best!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>My First AppExchange Product - RestEZE</title>
    <link href="https://adityanaag.com/blog/my-first-appexchange-product-resteze/" />
    <updated>2018-09-13T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/my-first-appexchange-product-resteze/</id>
    <content type="html">&lt;p&gt;The idea stemmed from the need to test multiple APIs our customer had allowed access to, from Salesforce IP Ranges only. This obviously meant - any tools like Postman were of little use here, and writing the same lines of code over and over again was time consuming. Building on this, and my previous experience with integrations, I started developing this playground called RestEZE (a named I derived from RustEze - a bumper ointment from the movie Cars, and a sponsor for “Lightning” McQueen) which would potentially solve this problem by providing a powerful GUI to test the APIs whenever I need, without having to write a single line of code.&lt;/p&gt;
&lt;p&gt;I realized while testing the APIs, that I was frequently using some functions like Hashing, Base64 Encoding etc. This inspired me to create a Utilities section which would allow a user to use these functions without writing any code.&lt;/p&gt;
&lt;p&gt;Later I decided to take it a bit further by adding a feature which would auto-generate a wrapper class for the response, and the required code stubs to use it, there by reducing a lot of the developer’s effort to parse the response or look for external tools to do this.&lt;/p&gt;
&lt;p&gt;No tool is good enough if it doesn’t remember your work, which is why there is a History section which tracks the last 100 callouts you made, and offers the ability to re-fire those.&lt;/p&gt;
&lt;p&gt;The app is now listed on AppExchange and can be downloaded and used for FREE!!!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://bit.ly/resteze&quot;&gt;Click here&lt;/a&gt; to see this app on the AppExchange.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/resteze-banner.png&quot; alt=&quot;&quot; title=&quot;RestEZE - A Native Salesforce Integration Playground&quot;&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Does your chat end when Apex Action is called from Einstein Bot</title>
    <link href="https://adityanaag.com/blog/does-your-chat-end-when-apex-action-is-called-from-einstein-bot/" />
    <updated>2018-09-18T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/does-your-chat-end-when-apex-action-is-called-from-einstein-bot/</id>
    <content type="html">&lt;p&gt;Unable to call an action from Salesfore Einstein Bot? Bot crashes when trying to fire Apex Actions? If you are one of those who is wondering why your Einstein Bot embedded live chat is ending the moment an Apex Action is fired or a dynamic choice is used, then you are not alone.&lt;/p&gt;
&lt;p&gt;This happens because of one of the 2 below reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;There is an exception in your Apex Class&lt;/li&gt;
&lt;li&gt;Your bot is unable to access the Apex Class&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can easily find and fix exceptions with the help of debug logs, but to fix the permission issue, lets meet the lesser known permission set &lt;strong&gt;&lt;em&gt;sfdc.chatbot.service.permset&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This is a permission set that gets created behind the scenes once you enable Einstein Bots. So what exactly does this permission set do? This controls the Objects and Apex Classes your bot can access in this org.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/sfdc.chatbot.service.permset.PNG&quot; alt=&quot;&quot; title=&quot;sfdc.chatbot.service.permset&quot;&gt;&lt;br&gt;
So whenever you want to use an Apex Class in the context of a bot, make sure that you have granted the permission in the above permission set. Same goes for all the Objects that you plan to use in your bot.&lt;/p&gt;
&lt;p&gt;Problem still not resolved? Comment below and I will help you fix it.&lt;/p&gt;
&lt;p&gt;For more information on Einstein Bots, download the cookbook from here - &lt;a href=&quot;https://sfdc.co/BotsGuide&quot;&gt;https://sfdc.co/BotsGuide&lt;/a&gt; I personally found this very helpful.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Output Invocation Mapping Error in Dynamic Choices of Einstein Bots</title>
    <link href="https://adityanaag.com/blog/output-invocation-mapping-error-in-dynamic-choices-of-einstein-bots/" />
    <updated>2018-10-02T00:00:00Z</updated>
    <id>https://adityanaag.com/blog/output-invocation-mapping-error-in-dynamic-choices-of-einstein-bots/</id>
    <content type="html">&lt;p&gt;I am sure most of you have started getting your hands dirty on Einstein Bots. If you have run into the below error when trying to build dynamic choices, welcome to the club.&lt;/p&gt;
&lt;p&gt;“An operation invocation must contain at least 1 output invocation mapping”.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/dynamic-choice-error.PNG&quot; alt=&quot;&quot; title=&quot;An operation invocation must contain at least 1 output invocation mapping&quot;&gt;&lt;br&gt;
A dynamic choice expects a List of values coming from the Apex Action, so you would have created a method like this&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token annotation punctuation&quot;&gt;@InvocableMethod&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Label &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Get Orders&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Order&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getOrders&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; contactIds&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;    
	&lt;span class=&quot;token comment&quot;&gt;//Your Logic&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You would have assumed that this method returns a List of Orders for a given contactId. But, an Invocable method is and must be bulkified as per Salesforce Best Practices. Therefore, if you observe the input parameter for the above method, its not just a single contactId, but a List of ContactIds.&lt;/p&gt;
&lt;p&gt;In plain English, if a contactId returns a List of Orders, then a List of ContactIds will return a List of List of Orders i.e., &lt;code&gt;List&amp;lt;List&amp;lt;Order&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So this is how your method should actually look like&lt;/p&gt;
&lt;pre class=&quot;language-apex&quot;&gt;&lt;code class=&quot;language-apex&quot;&gt;&lt;span class=&quot;token annotation punctuation&quot;&gt;@InvocableMethod&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Label &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Get Orders&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Order&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getOrders&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; contactIds&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;    
	&lt;span class=&quot;token comment&quot;&gt;//Your Logic&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once you do this, your output section in the Bot Builder looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://adityanaag.com/assets/images/posts/working-example-dynamic-choice-bots.PNG&quot; alt=&quot;&quot; title=&quot;Working Example for Dynamic Choices&quot;&gt;&lt;br&gt;
For more information on Einstein Bots, download the cookbook from here - &lt;a href=&quot;https://sfdc.co/BotsGuide&quot;&gt;https://sfdc.co/BotsGuide&lt;/a&gt; I found this very helpful.&lt;/p&gt;
</content>
  </entry>
</feed>