Category: Apex

Roll Your Own Salesforce “Lookup” Popup Window

August 12th, 2011, 3 Comments

Let’s talk about the standard salesforce.com “lookup” popup window for a few minutes. You know what I’m talking about.. this button right here It’s a handy little button that pops up whenever you need to search for related records. It does a pretty good job but it has some serious drawbacks: It’s virtually impossible to [...]

OpportunityAccessLevel Not Writable

March 17th, 2011, 9 Comments

I was working on a project the other day where I needed to dynamically add users to an opportunity’s Sales Team (OpportunityTeamMember object) so that users who do not normally have access to an opportunity based upon Org-wide security settings can work on the opportunity with other team members. One of the advantages of Sales [...]

Dynamically Group & Display Query Results

March 2nd, 2011, 10 Comments

I was working on a Visualforce page that displays the results of a query in separate PageBlock sections based upon a value in the query results. I ran into a small issue which took about an hour or so to solve, so I thought it might make descent blog fodder. The requirement for the page [...]

Fun with Salesforce Collections

January 6th, 2011, 6 Comments

The Apex language provides developers with three classes (Set, List and Map) that make it easier to handle collections of objects. In a sense these collections work somewhat like arrays, except their size can change dynamically, and they have more advanced behaviors and easier access methods than arrays. If you are familiar with the Java [...]

Force.com Programming Best Practices

October 21st, 2010, 23 Comments

  Wes and I are adding a few more topics to our Salesforce Handbook before we put it to bed and I thought a great topic would be programming best practices. I’ve never seen a “complete” list of best practices so I thought I would put something together based upon my experiences. I know I’ve [...]

Error – Portal account owner must have a role??

September 2nd, 2010, 5 Comments

I wrote the following test class for a PRM deployment and received this crazy error when running the test: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal account owner must have a role: [] I searched the message boards but couldn’t find any reference to the real culprit. My original thought [...]

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, 5 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, 12 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, 25 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 [...]

Feed

http://blog.jeffdouglas.com / Apex

WordPress Appliance - Powered by TurnKey Linux