2012 Calendar Year
Avoid Apex Heap Size Governor Limit in Visualforce
February 7th, 2012
I built this great Visualforce page where I display and allow for editing of many records at once. The initial business requirement was for only a few hundred records to be used in this application but, as usual, requirements morphed and now the business wants to be able to use this app for thousands of records. So guess what... we now encounter the "System.LimitException: Apex heap size too large" governor limit. WTF!
2011 Calendar Year
Apex Unit Test Tip for Checking Trigger Status
November 18th, 2011
Anyone with a lot of Apex code in their production Salesforce org knows that the more code you have the more tedious deploying new code to that org becomes. One of the orgs I work in has some triggers that get turned off and on for reasons that only the business owners understand. As any developer understands turning off a trigger is much easier than an Apex class, which is where we often encounter deployment issues.
Clone Salesforce Records with a Custom Button
August 13th, 2011
Almost four years ago I wrote the first post for this blog. That post had to do with passing field values in a URL in order to populate those values on an edit page. What's interesting is that the original post still gets a ton of traffic. So I'd like to expand on that topic again in this post and illustrate how you can build on that original logic in order to do something useful. In this case, I want to create a custom button that will clone a User record and remove certain fields so that I don't have to fill out so much information when I create new Users.
Anyone who is an admin for any larger enterprise knows that creating Users can get tedious and over time there are a number of custom fields that you probably have on your User records. The logic I'll demonstrate here will allow you to save a bit of time the next time you need to create a new User. Or you could just take the information from this post to create a "Clone" button on another object - like Account. Because the Account object doesn't have a standard "Clone" button and that may be useful to you as well.
Salesforce: Apex Code to Calculate DateTime Duration
August 5th, 2011
I've been developing a lot of batch Apex routines lately. The nature of batch Apex is that it can run whenever resources are available and process many records while being more flexible with platform governor limits. So I might schedule a job to run and it could take anywhere from a few minutes to many hours. Many variables impact the run time of a batch routine. Things like the number of records being processed or platform resource availability.
It must be my personality but I always like to know when a batch process has completed and I actually like to know how long it ran. Anyone familiar with batch Apex knows that there is a finish method, which is invoked upon completion of the batch logic. Within this method I will configure and send an email to myself with the start and end times of the batch process that finished.
Salesforce: Apex Code to Drop Leading Zeros
June 14th, 2011
Here is an example regarding the use of the pattern and matcher methods in an Apex class. For this particular code sample I am using the methods to check a passed text string for the occurrence of leading zeros in the string and removing them when they exist. The code I have written here was actually used on a project where I had to validate that User records contained a valid EmployeeNumber value. And, as you probably know, this particular field is editable by users and is stored as text in the database. Rather than go through the trouble of creating another Number type field on the User object I thought it would be easier and less disruptive to simply check the value when I needed to reference it in any Apex logic.
Salesforce: Apex Unit Test Tip for Filtering Test Records
March 30th, 2011
Today I participated in an online meeting, which discussed some of the "best practices" for testing Apex code, Visualforce pages, etc. One of the topics that was pretty much skipped but came up during the Q&A portion of the meeting was regarding how to ensure that the test code you write refrains from grabbing any actual live production data and only grabs the records created to facilitate the test. They discussed one way to do this but I have another and I thought it could be useful to other developers.
Depending on your experience you may not think that this is a very important topic. However, those of you that have worked with Enterprise organizations understand that these orgs may have tons and tons of records. For orgs that have millions of records in any given object it may be best to write test code that actually filters the data used within the unit tests so that the test actually completes in a timely manner. This can be especially important for deploying code because test coverage that runs for a long time can cause problems during the deployment process.
Modal Dialogs & the Yahoo! User Interface Library in Visualforce
March 2nd, 2011
I found this great post/tutorial (Modal Dialogs in Visualforce using the Yahoo! User Interface Library) regarding the use of the Yahoo! User Interface (YUI) Library within Visualforce pages. But what if you work for a business that uses Internet Explorer (IE) as the standard / supported browser across the enterprise? You get the security warnings dialog when accessing the Visualforce page, of course.
Other browsers offer warnings to users about accessing secure (https://) and non-secure (http://) items within a secure page but IE seems to be the most disruptive (in my opinion) to the User experience when working with Visualforce.
Dynamic Report Generation from a Custom Button
February 28th, 2011
I recently attended the Buffalo Salesforce User Group meeting. During the session a guest speaker conducted a demo of some development he did for his company’s production Salesforce org.
One of the items he touched on that spurred a lot of discussion was a custom button he built to pass a value to a report from a detail page of a given record. The resulting discussion was surprising because I really didn’t know that so many admins were unaware of the benefits of creating these custom buttons. And, after participating in the discussion, I thought that this would be a great topic for a blog post because there is so much that you can do if you understand this relatively simple trick.
Visualforce Component for Locale Based DateTime Display
February 5th, 2011
Sometimes, I really dislike Visualforce... Last week I spent a ton of time troubleshooting a display issue for a page that was built by another developer. The issue was that the DateTime field for an object was not displaying properly. It was showing the value in GMT and not the timezone of the user. After spending way too much time reviewing everything I decided to build a custom Visualforce component to eliminate the problem altogether.
sObject Describe Result for Visualforce Picklist
January 17th, 2011
More than a while ago, I wrote about populating query results to a picklist for use in a Visualforce page. That post receives a lot of traffic and I get some additional emails regarding that topic. So I thought I would put together another post similar to that one but with a bit of a twist.
In the sample I will cover in this post I am going to show you how to use the methods for the Describe Result sObject in order to create picklists within Visualforce pages.
2010 Calendar Year
Custom Button to Execute JavaScript
July 14th, 2010
I make everyone on my team track their time using a custom Time_Card__c object in our Salesforce org. At the end of each pay period I have to update the Status field on these Time_Card__c records to something and most often the status is set to "Paid." Since it can be frustrating to update many records repeatedly to the same value and some folks don’t like using the Excel Connector or Data Loader to perform mass updates, I thought that it would be easier to create a custom button where I could select the records from a Time Card list view or Project Detail page related list and then click a button and have Salesforce update the records in mass via JavaScript.
Batch Apex - Invalid Query Locator
July 13th, 2010
I recently encountered an "Invalid Query Locator" error while developing a batch Apex class that took me too long to resolve. I was able to trial & error my way through it until I got the code to work but I found it very frustrating that I was unable to find a solution on another developer board or blog. So here’s my attempt at helping others that may encounter this problem.
Create Custom Report Type for Salesforce Ideas
June 21st, 2010
Have you rolled out the Ideas functionality for your Salesforce org? If so, do you have the need to report on the Ideas by profile or role or some other field? An administrator at one of the businesses I support contacted me and asked why he couldn’t create a report to show the number of votes by specific Users in his org. The management team decided that they would hold a competition to see who is using the Ideas functionality the most and they weren’t able to create a report to provide the details they were seeking.
Pre-popoulate Lookup Fields via URL
June 18th, 2010
A few years ago I wrote a post about how to populate information into Salesforce fields by navigating the User from page to page. I received a lot of good feedback on that post and the logic for it pretty much remains unchanged today. The intent of that original post was to identify how an administrator could use button overrides to get a User from one page to another and still auto-fill some of the details for the next page on behalf of the User. Go here to see my original post.
Apex Trigger to Reassign Contacts and Open Opportunities
January 28th, 2010
Standard Salesforce functionality allows for the reassignment of Contacts and open Opportunities when the Account to which these records are associated is reassigned to a new User. Clicking the "[change]" link next to the Account Owner field on the Account detail page will allow you to step through a process by which you select a new Account owner and save the changes. Once the changes are made the system will go out and reassign all Contacts and all open Opportunities owned by the old Account Owner to the new Account Owner. This is useful and so automatic that you may not even be aware that it happens.
2009 Calendar Year
Convert Existing Triggers to Allow For Bulk Processing
December 14th, 2009
One of the most difficult concepts for me to get my head around after the Winter ’10 release was that of bulk triggers. In the release documentation I read a line stating "All triggers are bulk triggers by default, and can process multiple records at a time."
Insert Null Values Using Data Loader and Bulk API
December 3rd, 2009
I learned something new today and thought it should be passed on. In an earlier post I wrote about how the Data Loader will not insert null values when using the Bulk API. It turns out that the API will insert null values but you need to use the text "#N/A" as the value instead of leaving the value blank.
Avoiding Spam with Web-to-Lead
November 14th, 2009
Earlier this week I attended the Denver Salesforce User Group meeting. One of the attendees was a new user and asked the group if others were using the web-to-lead functionality. Some were capitalizing on this functionality but, to my astonishment, not everyone.
Enabling the Bulk API with the Salesforce Data Loader
October 30th, 2009
Part of the Salesforce Winter ’10 release was something that the release notes and folks at salesforce.com refer to as the Bulk API. Also, you may have read that the "Bulk Loader" is now available and it will now take longer to count the records than it will to load them, blah, blah, blah...
Custom Picklist in Visualforce Page
April 7th, 2009
Let’s say that you’re building a Visualforce page and you want to provide a picklist option for your users on the page. If the field where you want to store the selection is a picklist then you have no issue because the field definition will define that the page display a picklist when the Visualforce page is rendered. However, let’s say that you want to display a picklist option based on a query from another object. How would you do that?
Extended Mail Merge
March 18th, 2009
I was on a call today with a client that constantly uses the Mail Merge functionality of Salesforce. It is important for their business to send out a lot of direct mail pieces. Anyway, they were unaware of the Extended Mail Merge capability of Salesforce and it surprised me because they have been Salesforce subscribers for many years now. So I took a few moments to demonstrate the Extended Mail Merge features and I also thought that this would be a good topic to write about on the site.
Determining Time Zone Offset
January 17th, 2009
I ran into an issue today and I’ve encountered it in the past but I couldn’t find the code I originally wrote to resolve the problem. For this reason, I am going to post the code and the issue here so I can find it again in the future. Additionally, it might prove useful for some other developers and they should feel free to take it from this post.
Earlier Than 2009
Opening Trusted IP Ranges
August 27th, 2008
As you know, salesforce.com has taken many steps to ensure that their app is secure. The primary security features call for the use of a security token appended to the standard Salesforce login credentials or a confirmation message to enable login from specific computers/laptops. For most Salesforce customers these security features were a welcomed addition but to developers these security features caused some headaches.
Grant Login Access Using a Link
July 10th, 2008
If you have ever been an administrator of Salesforce for any organization, you have inevitably had to request that a user grant you login access in order to assist them with a question or issue for which they requested your assistance. I know whenever I needed someone to grant me login access to their Id I would send them an Email with instructions similar to...
Highlighting Tab from Within sControl
February 22nd, 2008
When we were building the Messages Application for the AppExchange we encountered a little glitch that I think many Salesforce developers encounter but not all know how to remedy. The problem we ran into was that at times the highlighting of the Home tab would go away as we navigated to some of the sControls used within the app.
Hiding & Displaying Buttons in the Page Layout
February 21st, 2008
Lately I’ve been seeing more and more postings on many of the Force.com message boards around the use of buttons inside the Salesforce application. Primarily people are interested in passing information using buttons and in some cases hiding buttons when certain criteria are met. Since this seems to be a hot topic lately I thought I would share with you a simple way to accomplish the goal of displaying a button when certain criteria is met and otherwise hiding the button.
Eliminate Scrollbars in sControls
December 13th, 2007
Many new salesforce.com AJAX developers ask me how I am able to build my sControls into a frame and get the sizing setup in such a manner to prevent scrollbars. Over the years I’ve tried many different JavaScript functions but found that one works better than any I’ve seen.
Custom Colors and Icons
November 29th, 2007
I recently was asked about the custom colors and icons that we use for our Link Management Application and the person was wondering how they could incorporate the use of those colors into their sControls. Since I had to put all of that information together for our App, I decided why not share that with everyone as some type of reference? So here’s a little background on why this information is useful.
Date Selection Lookup
October 24th, 2007
Back in the day salesforce.com used a popup window to allow for date selections on their edit screens. Their new functionality by which the date is selected from inside the page itself is much more slick and I wanted to take a few minutes to show you how this works.
Mimic Task Subject Lookup
October 23th, 2007
From time to time, there may be a need to mimic the lookup functionality from standard salesforce.com edit pages into a custom sControl. In this example, I am going to show you how to mimic the lookup field for "subject" that you would normally find on the Task edit page.
Create Dynamic Picklists
September 6th, 2007
Have you ever created an sControl and needed to use a picklist? If you’ve done this and hard-coded the picklist values into the sControl code then you understand that it can be a pain if the picklist options (or business requirements) change.
Pre-populate Fields Using URL Parameters
September 5th, 2007
For my example I am going to pre-populate some fields on the contacts object. Now the contacts object (like all salesforce objects) has what salesforce sometimes refers to as a front door for the URL. Quite simply the front door for the contacts tab is "/003/o". The front door for a new contact would be "/003/e". If you want to see what the front door is for any object simply click the tab for the object. The front door is the three characters directly following the ".salesforce.com/" portion of the URL while you are on the tab’s "home" screen. Further examples; Opportunities home is "/006/o", Accounts home is "/001/o". If you want to add a new record for the object you simply change the "o" portion of the front door to an "e". I know I wrote that the front door was three characters but I think you get my drift here





