Category: Apex
Writing an Inbound Email Service for Salesforce.com
March 12th, 2010, 4 Comments
Creating an inbound email service for Salesforce.com is a relatively straight forward process but there are a few thing to explain to make your life easier. The email service is an Apex class that implements the Messaging.InboundEmailHandler interface which allows you to process the email contents, headers and attachments. Using the information in the email, [...]
Locking sObject Records
March 9th, 2010, 1 Comment
I don’t see this discussed often, but Salesforce.com has the ability to lock sObject records while they are being updated to prevent threading problems and race conditions.
To lock records, simply use the FOR UPDATE keywords in your SOQL statements. You do not have to manually commit the records so if your Apex script finishes successfully [...]
Passing Parameters with a CommandButton
March 4th, 2010, 6 Comments
This post is a slight tweak of yesterday’s post, Passing Parameters with a CommandLink. In theory you should just be able to switch out the CommandLink component with a CommandButton component and be golden. However, not so fast. There seem to still be a bug with the CommandButton component.
Here is the Visualforce page with the [...]
Passing Parameters with a CommandLink
March 3rd, 2010, 3 Comments
Here’s a small example of how you can pass a value to another method via a command link for Salesforce.com. When the link is clicked, the setter fires for the public member nickName. The button click then calls the processLinkClick method where you can do something like process the variable further with DML statement or [...]
Relationship Lookup Objects in Triggers are NULL?
February 23rd, 2010, 1 Comment
I see this question once in awhile on the Salesforce.com message boards so I thought I’d put something together. So in this scenario you have a Sales_Order__c custom object which has a lookup relationship to Opportunity. When processing the Sales_Order__c records in your trigger, you want to access some fields on the Opportunity via the [...]
Using List Custom Settings in Salesforce.com
January 7th, 2010, 15 Comments
Salesforce.com recently introduced Custom Settings in Winter ‘10 which allows you to store custom data sets and associate them on an org-wide, profile or user basis. Custom Settings are essentially custom objects that are exposed in the applications cache and are accessible via their own API.
You can certainly build your own custom objects to [...]
Calling a REST Web Service (JSON) with Apex
January 6th, 2010, 2 Comments
Cross-posted at the Appirio Tech Blog.
Using JSON RESTful Web Services with Salesforce.com opens up your org to a number third-party integration opportunities (Google, Yahoo!, Flickr, bespoke, etc.). JSON support isn’t baked into the Force.com platform but Ron Hess at Salesforce.com has created a JSON parser which will do the heavy lifting for you.
Last month [...]
Automating Salesforce Approval Processes with Apex Triggers
January 4th, 2010, 7 Comments
This question came up on LinkedIn asking how to automatically fire off an approval process when an Opportunity reaches 30% probability. This example was on my to do list so I thought I would knock it out quickly.
The trigger fires when an Opportunity is updated and is submitted for approval if the Opportunity’s probability has [...]
Problems Parsing JSON Responses with Apex
December 28th, 2009, 6 Comments
A couple of weeks ago I wrote an article and small demo of a REST web service call returning XML. It was my intention to do the same demo using JSON. However, I ran into a small sang; I couldn’t get the Apex JSONObject to work. I worked on the code for most of the [...]
Calling a REST Web Service (XML) with Apex
December 4th, 2009, 3 Comments
This is a cool little example of calling a REST web service with Apex. You enter your address and the Apex code fetches the geo coordinates from Yahoo! Maps. The service returns the data as XML.
If you want to run this demo in your own org, you will need to do the following:
Add a “Remote [...]


