Salesforce.com Summer 12 Awesomeness

04/30/2012

The salesforce.com Summer 12 Release Notes are out and once again is like Christmas…or Hanukkah…or Kwanzaa…or your birthday…(or some awesome event with presents!) for salesforce.com admins and devs. It’s this wonderful time of year when we once again get to read about all the great new features coming up in the next release. I’ve read through the release notes and there are tons of great features coming but from a developer perspective these are the features that excite me most.

Sorting Lists of sObject and other complex data types
This feature is near and dear to my heart. People have been trying to figure out the best way to do this for 5+ years! I even put together a little how to article on the developer.force.com wiki before I even had this blog. This is a great feature and anyone who has built custom sorting methods will truly appreciate this feature.

Dynamic Instantiation of Apex Classes
Also known as Reflection but you have got to admit “Dynamic Instantiation of Apex Classes” sounds way cooler. I’ll be the first to admit that I don’t know the best ways to utilize this feature but I know it is a massive improvement and starts to give Apex features that make it a true fully fledged programming language.

JavaScript Remoting Enhancement for Manage Packages
Let’s say you have two versions of an app. A managed package version and an unmanaged package version. The manage package version will add a namespace to all of the Apex classes. With JavaScript Remoting you previously had to hard code the Apex class name and method. This required either managing two different versions of the JS code or hacky workarounds in the JavaScript to detect namespaces and call the correct class name with or without the namespace. In Summer 12 you now don’t have to worry about this namespace problem.

In this truly superb example we have the following AccountUtil class with the namespace SuperProduct and it has a method that returns a list of Accounts.

global class AccountUtil{
    @RemoteAction
    global static List<Account> getAccountList(){
        return [select Id, Name from Account limit 10];
    }
}

Previously you would have to hardcode the namespace in the JavaScript code like so:

SuperProduct.AccountUtil.getAccountList(function(result, event){
    //process response
});

With Summer 12 you no longer need to hardcode the namespace and the way you call JavaScript Remoting functions is slightly different.

Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.AccountUtil.getAccountList}',function(result, event){
    //process response
});

Hooray! No more hardcoding the namespace! It will be interesting to see if the merge field syntax of {!$RemoteAction.AccountUtil.getAccountList} also works in static resources. As of today it’s not possible to user merge field syntax in a static resource.

Metadata REST API
You may not know this but the current Metadata API sucks. Sorry salesforce.com. I’m sure at one point in time it was really cool, but it is not anymore, and I’m sure a ton of people at salesforce.com would totally agree with me. If you have ever tried to use it you will know it requires building zip files and sending them to salesforce.com to deploy or modify components. It also requires unzipping file responses. This is simply not very cloud friendly and it’s a pain to work with. Oh, and did I mention it’s terribly slow. I have high hopes for this new REST Metadata API and I’m really looking forward to it.

Also, as the owner of an org with 15,000+ reports I’m hoping this API finally provides a better way to find reports and views that are using a specific field in the output or the criteria.

As of posting this it doesn’t look like the reference guide for the Metadata REST API is out yet.

EDIT: This first version of this API will also be read only.

Run Apex on Package Install/Uninstall
Need some Apex code to run when a user or customer installs a Managed Application? Now you can do this. Previously you had to either A) make the user going through a structured setup process or B) in your application code check to see if everything is setup properly the first time it runs and if not call some sort of setup method. Both not very elegant.

Allow Reparenting Option in Master-Detail Relationship Definitions
What is that? Do you hear something? Yup, I hear something…IT’S ANGELS SINGING!!!!! This nugget of incredible awesomeness was buried at the very bottom of the release notes but it is freaking HUGE as far as I’m concerned!

In Summer ’12, administrators can now allow child records in master-detail relationships to be reparented to different parent records by selecting the Allow reparenting option in the master-detail relationship definition. By default, records in master-detail relationships can’t be reparented.

This was such a pain before. First you need to build Apex code to clone the the child record. Then you also had to clone everything else attached to this child such as tasks, events, attachments, other child custom objects, and more! This feature makes be very very happy.

New Lookup Relationship Options
This bad boy was also buried at the end of the release notes but it also gets me very excited. Lookup relationships now have a ton of enhanced functionality when it comes to deleting the “parent” record in a Lookup relationship. Let’s check out the official wording:

• Clear the value of this field. This is the default.
• Don’t allow deletion of the lookup record that’s part of a lookup relationship.
• Delete this record also.

Here is an example. On an Opportunity we have a lookup field to the Account object called Primary Partner. Now if the Account in the lookup field ever gets deleted the value on the opportunity will get wiped out. Currently the only way to prevent this from happening is with an Apex trigger on the Account being deleted. Now this can be accomplished with clicks not code! This feature also help prevent the orphaning of “child” records.

The ability to enable cascade delete functionality with Lookup relationships will also be available. The line between Lookup relationships and Master-Detail relationships just got very very blurry, in a totally great kind of way. Now the only significant difference between Lookup and Master-Detail fields is Roll-Up Summary field functionality and based on these changes I would guess that Roll-Up Summary functionality for Lookup fields is not far away. Actually, I wouldn’t be surprised to see these two field types rolled in to one and the behavior controlled with field specific settings.

[EDIT] Another difference is Master-Detail relationships also inherit record access permissions. Lookups do not.

The last few feature release from salesforce.com have had one or two great features but the Summer 12 release is the first release in quite some time that has a treasure trove of great new features that will immediately have an impact on day to day admin and force.com development. Can’t wait for Dreamforce and Winter 13!