Subscribe

  • Subscribe  

Using Force.com as a Flex back end…

Posted by Harry Vikatos | August 12, 2008 .

or depending how you see it, using flex as a force.com application front end.

force.com stack

Either way salesforce is one of the PaaS (platform as a service) providers, that sees in Flex the technology for adding rich user interfaces to its applications. As we’ll have the chance to point out in numerous occasions, RIA’s and SaaS (software as a service) seem to be going hand in hand. Furthermore Air’s offline capabilities add a lot of value to the SaaS proposition for enterprise applications that need to be operational independently of connectivity.

So additionally to Saleforce’s own UI development tool (Visualforce), a Flex SDK  is provided, that enables developers to build Flex applications that interface with Force.com backend i.e. the enterprise grade platform used by Salesforce CRM, one of the greatest SaaS  success stories. The SDK is basically a library in the form of SWC (actually one for web applications and one for Air) offering an AS3 wrapper to Force.com’s Web Services (SOA) API.

So here’s a quick walk through the steps to build a first application:

Open a developer account at force.com

Once you do that you get a standard application data scheme and some sample data, coming from the CRM functionality. Go ahead and setup your application to define custom objects and relationships, using salesforce web pages. There are far more capabilities here (workflow, triggers, etc)

Download the Flex SDK, read through some sample apps and go ahead to build a Flex client that connects to your Force.com account. Watch out for some points that may get you stuck though, especially when building a web app:

  • explicitly use http protocol as https is the default and requires support from the web server running your flex app.
  • explicitly allow your salesforce app to accept http connection (setup> Security Controls> Session Settings> deselect ‘Require secure connections)
  • setup your password to combine the user’s password appended with your security token that you get from your application web environment at salesforce (setup>My Personnal Information> Reset my security token)
  • write your app to be deployed either on your own web server or embedded within salesforce pages (as an s-control; an equivalent of a widget in force.com terminology)

Here’s a very simple Flex piece of code that connects to your force.com account, when deployed on your own web server:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” xmlns:salesforce=”http://www.salesforce.com/”
    implements=”mx.rpc.IResponder” creationComplete=”init();” xmlns:objects=”com.salesforce.objects.*”>
<salesforce:Connection id=”force” protocol=”http”/>
<objects:LoginRequest id=”request”
    username=”email address”
    password=”password+security token”
    callback=”{this}”/>

<mx:Script>
    <![CDATA[
        import mx.rpc.IResponder;     

        private function init():void {
            force.login(request);
        }
        public function result(data:Object):void {
            //now you can retrieve data by querying your backend
        }
        public function fault(info:Object):void {
            //some error handling code        }
    ]]>
</mx:Script>
</mx:Application>

So in all a rather straightforward procedure, although problems could arise from the lack of documented issues (2nd bullet above took me a couple of days to figure out). An effort worth making though, if an enterprise grade application targeting salesforce’s audience, is what you ‘re after.

More on force.com platform and flex as we further dig and share our findings.

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Related Posts

<

Error. Page cannot be displayed. Please contact your service provider for more details. (7)


Direct TV Offers - usdirect has the best directtv deals