Archive | June, 2008

Hacking Salesforce – Part 2 (Release Management)

Salesforce Release Management

Salesforce always advocates us to make all the changes through its UI. It is nice but hardly a solution for a corporation. In a corporation, we used to develop everything in dev, launch to QA and test it, then launch to production. Salesforce claims its approach can shorten the release cycle. However, I don’t think we want to do thing in this way. For example, if we have hundred of fields to add and the application cannot be used until all of them are in place, what will you do to minimize the impact of users currently using your app? How can we rollback all the changes? How to test the changes before releasing them? Yes, you may get around this via switching layout or making new objects and fields available only for admin user. However, what if we don’t even want our developers accessing production box because the data there is sensitive.

All in all, we want a solution that we are able to develop on our sandbox, test it and push a button to release all the changes to production. To my dismay, I don’t see Salesforce provides us end to end solution in this aspect. To work around, I tell my team to do all the changes in the sandbox (Salesforce provides one if you are in enterprise edition but it only has metadata in it) and manually move the changes to production after test. It is a tedious process and error-prone. Finally, I decide to search around and luckily I found a way to achieve my goal.

Use Force IDE

Force IDE is released that works on the new Metadata API released on Summer 08. It is an awesome tool. Through this, I am able to back up my production metadata in xml format and put them in version control system (ie SVN). With the help of SVN, I am able to tell who has changed what, do a diff on different versions and rollback. It is a great tool for us. But when I look into this tool, I have faced some of the issues. Below are some of my findings:

  1. I cannot remove or rename existing fields.
  2. There is no standard objects.
  3. There is no approval processes
  4. If you custom objects have circular dependency, you cannot simply copy 2 .object files into the object folder and assume Force IDE will resolve it for you.
  5. I cannot move apex classes to production box.
  6. I lose the association between S-Control and button.

However, I am able to get around these via:

  1. Rename and delete fields using SF UI.
  2. Modify the package.xml to enable standard object synchronization. (detail)
  3. Use SF UI to add approval process
  4. Manually create the custom object via SF UI first. Then you can copy all the fields to it via Force IDE.
  5. Apex class cannot push to production unless you test it and deploy it via the migration tool.
  6. Manually associate the S-Control with button via SF UI.

However, although we cannot make release management simply pushing a button, we can live with that as Force IDE already does a lot for us.

Backup Strategy

Now we know how we deal with metadata and simplify the release management via Force IDE. How about backup the data? Salesforce provides us DataLoader tool that we can use to export Salesforce data in CSV file format. Apart from that, you can import the CSV file back to Salesforce. 

 

Leave a comment Continue Reading →

Hacking Salesforce – Part 1 (Resource)

Introduction of Salesforce

My company uses Salesforce as its online CRM solution. And I happen to be in charge of this team. So, I get a chance to mess around with it. The more I look into it, the more I like the idea and infrastructure behind it. I am not going to dig deep into the beauty of its architecture in this post. Instead, I would post some useful resources to get you to start playing with it. To begin with, I would open a developer account in force.com. The developer account gives you all the enterprise edition feature with no time limit. The caveats are that  you can only have 1 admin and 1user account, and your account is limited to several MB storage space only. However, it is good enough to get a good taste of Salesforce. After you sign up, you can go to its invaluable Wiki and Discussion Boards to obtain tips and starter tutorials. Salesforce also made 2 ebooks available. They are:

  1. Introduction to the Force.com Platform – for beginner
  2. Force.com Cookbook – for intermediate user

Now I assume you can do the followings:

  1. Create custom objects and fields via SF UI
  2. Build object relationships
  3. Create validation rule and approval process
  4. Customize the layout for object (very limited without Visualforce)
  5. Create S-Control
  6. Mess around with Salesforce Security Model.

Great! You are now empowered by Salesforce to build a solution for your company. However, you may encounter issues related to its UI limitation like you cannot hide a field when someone selects a particular field on a picklist (resolved by Visualforce) or you cannot populate another object when one object is saved (resolved by Apex Trigger). You may find a way to get around this problem but I bet it is not going to be pretty. If you are interested to unveil the true power of Salesforce, keep reading.

Become a expert user

If you are interested in solving the UI and functionality limitation above, please take a look at the following ebooks:

  1. Apex Developer’s Guide
  2. Visualforce Developer’s Guide

Become a developer

OK. You are like me, the tools above may not satisfy you completely. To fully control its UI, I would use Flex. To fully manipulate the data model, I would like to use its API. If you are interested in building the next killapp on top of Salesforce platform. Here are some of the APIs that you may be interested:

  1. Apex Web Services API – Covers the SOAP API in all its glory. I personally wish this was REST, but SOAP is better than everything but REST.
  2. Apex Metadata API – A newer API, the Metadata API allows us to define the structure (fields and relationships) of our custom objects via XML rather than via the declarative point-and-click interface. Unfortunately there’s no Metadata API available for standard objects (Contacts, Accounts, Opportunities) yet, but I expect that to change this year.
  3. Apex AJAX Toolkit API – The AJAX Toolkit is primarily used with S-Controls, which are being phased out in favor of Visualforce. To be honest, the AJAX Toolkit has always seemed like a workaround hack to me, and hopefully the combination of Visualforce and Apex Code will render it obsolete.

I will keep this post updated for the new features Salesfoce releases in the future. :mrgreen:

  

Leave a comment Continue Reading →

Business Intelligence – Part 1 Pentaho

Getting into Business Intelligent World

When I dig deeper in business intelligence, I found out that it is a huge topic ranging from reporting to data mining. Like all the knowledge acquisition plan, I put a series of milestones for myself. If you are interested, here is my list:

Get and prepare your data

  • Data collection – log processing, web services (SOAP and REST), RSS, screen scraping and more.
  • Data preparation and crunching – ETL (Kettle)
  • Data storage – data warehousing

Visualize your data

  • Reporting and Charting (Pentaho as server and Flex as frontend)

Analysis your data

  • Data modeling
  • Data analysis (OLAP)

Get smart of your data

  • Collective intelligence
  • Data mining

Introduction of Pentaho

Firstly, I want to see whether there is any out of the box  open-source solution that captures what I am trying to do here. If so, I can reach my goal much faster. Yes. It has to be open-source b/c I don’t have $$ and I don’t want to be just a user. After doing my homework a bit, I found out an open-source BI tool named Pentaho that looks pretty solid. So, I decide to dive deep to this. Like all the tools I mess around with, I want to integrate Pentaho as library. However, I don’t find anything on the Net that shows me how to do it. I am looking into its download and checkout its pentaho-sample project. What it shows me is how to use their tools to create a report on their systems using their UI. I definitely need more!

After few days of efforts, I managed to pull out all the unnecessary dependencies from pentaho. The heart of Pentaho is its xaction interpreter. The approach Pentaho uses is to write adapters, plug into its framework and use xaction to wire them up in a workflow fashion. In fact, most of its functionalities come from other open-source projects like quartz for scheduling, shark for workflow engine and jfreereport for reporting. I don’t think their xaction is clean but I do like their architectural approach.

Enough talk, lets start! Here I would use series of articles to cut your learning curve and show you how to get yourself familiar with Pentaho as a developer rather than user. First thing first, follow the articles below to set up your environment. 

  1. http://wiki.pentaho.com/display/PentahoDoc/07.+Debugging+with+the+Standalone+Platform+Project
  2. http://wiki.pentaho.com/display/PentahoDoc/Building+and+Debugging+Pentaho+with+Eclipse
  3. http://wiki.pentaho.com/display/PentahoDoc/Manual+Deployment+of+Pentaho

Leave a comment Continue Reading →

Flex Remoting and Session Management

Power of BlazeDS

Recently, I found out that Adobe has released BlazeDS (subset of LiveCycleDS) that has 4 main advantages:

  1. AS3 to Java object communication (no XML passes back and forth is needed!)
  2. Boost up performance b/c AMF is a binary protocol
  3. Built-in proxy support that gets around the cross domain security issue from Flex in ease.
  4. Allow push messaging

I have followed the guideline and set it up. Now my Flex application can call my Java object method without passing xml back and forth. It is awesome! During the setup process, you may experience your flex cannot find the destination set up in the server.

The error “[MessagingError message=’Destination ‘SomeBean’ either does not exist or the destination has no channels defined (and the application does not define any default channels.)’]”.

The trick here is to add a services argument to the mxmlc call, something of the form below should do the trick! 

-services “[local path to your java project]/WEB-INF/flex/services-config.xml”

Now you may start enjoying how AS3 talks to your Java Object. However, if  we bypass the Servlet layer in the code, how can we carry session across remote method calls? Great that I have found out how to handle it via this article. In short, you can access Session from your Java object via:

FlexContext.getFlexSession()

Here is the quote I got from the BlazeDS developer guide.

The FlexContext class is useful for getting access to the session and the HTTP pieces of the session, such as the HTTP servlet request and response. This lets you access HTTP data when you use a Flex application in the context of a larger web application where other classes, such as JSPs or Struts actions, might have stored information.

The FlexSession class provides access to an ID and also provides setAttribute and getAttribute functionality. This is useful for storing data on the server that doesn’t have to go back to the client. However, FlexSession is not cluster-aware; if a client connects to a different server in the cluster, the client receives a new FlexSession. Nothing stored in the FlexSession attributes is persisted for clustering purposes. The FlexSessionListener class is useful for monitoring who is connected. You add a listener by using the static method to track new connections being made. You receive a reference to the session that was added. Each session can then report when it is destroyed to those same listeners. You use this for monitoring connections that close, and also to clean up resources.

When I looked into the source of FlexContext, I noticed that it leverages ThreadLocal to store context info like request, response and session.

    private static ThreadLocal sessions = new ThreadLocal();  
    /**
     * The FlexSession for the current request.  Available for users.
     */
    public static FlexSession getFlexSession()
    {
        return (FlexSession)sessions.get();
    }

Reference

Below are some of the useful references I have read so far:

  1. Jim Boone’s Blog

 

Leave a comment Continue Reading →

Power up Salesforce UI via Flex

Get started

Follow the steps below to get your first Flex salesforce app up in Salesforce.

  1. Register a developer edition account from Salesforce. Note: Dev account never expires but the account does come with a few limitations. You can only have two users, one an admin account so that you can build and install applications and the other a normal user account so you can test your work from the perspective of a normal user. The account has a 2MB data limit and you can send mass email. However, It is totally fine for playing around all the features that Salesforce provides.
  2. Download the Flex Salesforce Toolkit (ie. force.com-air_flex-1.0.zip). This toolkit provides the needed libraries to communicate directly with your salesforce.com database records from within a Flex application, using native ActionScript packages and returning strongly typed classes.The documentation on the classes can be found here.
  3. In this zip file, there is a library called as3Salesforce.swc in the bin directory just off the root of this zip file. It is the library you need to associate to your Flex project.
  4. Create a Flex project and include the swc library in it.
  5. You can follow this screencast to get your first project up.

What you can do after that?

Now you have your Flex application run locally in Salesforce. Here is my TODO list and the solutions of each one.

  1. Run your app under your own website and pull info from Salesforce using the same api.
  2. Run your app under Salesforce and have it pulled data from your system thru Flex Remoting (HTTPService, WebService, RemoteObject…etc).
  3. Can we use the API to pull Salesforce metadata like SControl?
  4. How can we provide our application via Apex Exchange?
  5. How can we use the Salesforce Flex AIR Toolkit to make have your application deal with Salesforce in offline mode? Look into this article.

What Flex gives you but not original Salesforce UI?

Now you know how to integrate Flex with Salesforce. But what problems that Flex helps us solving but not the original Salesforce UI?

  1. Capture user events on the fly and display additional fields or populate bunch of fields.
  2. Visual the data via Flex charting.
  3. Full control on the layout, and look and feel.

  

Leave a comment Continue Reading →