Category: Apex
Managing the Heap in Salesforce.com
August 16th, 2010, 5 Comments
With the Spring ’10 release, Salesforce.com removed the limit on the number of items a collection can hold. So now, instead of ensuring that your collections contain no more than 1000 items, you have to monitor your heap size. Here are some strategies on how to write Apex scripts that run within these limits. First [...]
Using the Salesforce.com OAuth Playground
July 28th, 2010, No Comments
My article on developer.force.com, Using OAuth to Authorize External Applications, shows how to develop external Java applications that use OAuth to access your Saleforce.com data. But what if you want to do the opposite? What if you need to write an application on the Force.com platform that uses your data from Google, Twitter, LinkedIn or [...]
Email a Document with Salesforce.com
July 22nd, 2010, 5 Comments
After my last post, Create and Email a PDF with Salesforce.com, I received a few comments whether it was possible to do the same with Document stored in Salesforce.com. Could you choose a Document and then send it via email as an attachment? The short answer is yes! However, I tried to do it from [...]
Create and Email a PDF with Salesforce.com
July 16th, 2010, 5 Comments
This is a continuation of my post a couple of days ago, Attach a PDF to a Record in Salesforce, and shows how to dynamically generate a PDF and attach it to an email. The code is fairly similar and has the same issue with testing the PageReference getContent() method. You can run this demo [...]
Attach a PDF to a Record in Salesforce
July 14th, 2010, 6 Comments
Salesforce.com makes it extremely easy to generate PDF documents on the fly by simply using the renderAs=”pdf” attribute for the <apex:page> component. It’s also a snap to attach these PDFs to records as Attachments. Below is a small Visualforce page and Controller that generates a PDF and saves it to an Account. Note: there is [...]
Building a Dynamic Search Page in Visualforce
July 13th, 2010, 14 Comments
I brushed this code off and thought it might be useful to someone as a starting point for a dynamic search page. It has some cool functionality including passing search criteria via Javascript to the controller, search as you type, sorting of results by clicking on the column header plus much more. Hope you find [...]
Using RSA-SHA1 with Salesforce Crypto Class
July 6th, 2010, No Comments
This is a rather obscure post but it will definitely come in handy to someone trying to use the RSA-SHA1 algorithm with the Salesforce Crypto class. I’m spent the past two days trying to hook up OAuth using Apex and various Google Services. The standard HMAC-SHA1 algorithm is fairly straight forward with OAuth and Google [...]
Testing Salesforce.com Controller Extensions
June 2nd, 2010, 1 Comment
One thing that salesforce.com is working on is providing developers with a better testing environment. Salesforce.com requires you to write test cases to deploy your code to production but sometimes the process can be painful. Given the lack of something like jUnit you have to implement your own setup and test procedures. You’ll need to [...]
Uploading an Attachment using Visualforce and a Custom Controller
April 28th, 2010, 3 Comments
This is a follow up post to Uploading a Document using Visualforce and a Custom Controller showing an example for uploading an attachment for a Contact. The Visualforce page and Controller is very similar with a few exceptions. Attachments are different than documents and are only available for the following objects: Account Asset Campaign Case [...]
Create a New Record in Force.com Sites
April 27th, 2010, 8 Comments
So someone asked me yesterday for some code to allow external users to create contact records in Salesforce.com. They needed a simple form where people could enter the details and once submitted receive a confirmation of what information was entered. Here’s what the final page that was developed looks like. You can try the code [...]










