Posts Tagged ‘visualforce’

Salesforce-to-Salesforce Mashup: 100% Native Force.com Apex Solution - March 16, 2009 at 5:32 am

Follow Reid: Twitter.com/ReidCarlberg. A few people on my team contributed to this at different points.  Props to Shoby Abdi for getting it all together.  Twitter.com/ShobyAbdi.

I recently ran into a challenge regarding a Salesforce-to-Salesforce mashup.  We didn’t want to move the data (traditional integration, S2S/org to org sharing), but we also wanted to keep the solution as "clean" as possible — the simplest possible implementation with the fewest possible moving parts.  This article is a walk through of how we solved it.  I’ve included some lessons learned at the bottom.

Background

* Our goal was to create a mashup without a third party mashup provider.

* Although Apex facilitates callouts to external services, the API specs clearly state that Apex callouts are not designed to call full Salesforce.com API based webservices, so we knew we had to avoid that route.

* We wanted to have avoid creating a large number of dedicated Apex "stubs" on the data provider org.

* In addition to pulling information from the data provider org, we wanted to be update to update a record.

Here are the two screen shots that we ended up with.  Note that both are on the calling org.  In the first, you can see where a query has resulted in data coming back.  In the second, you can see where we’ve updated a field and refreshed the query results. Neat!

Screen 1: The query "Select Id, Name, BillingStreet from Account where BillingState = ‘CA’" results in two records.

Salesforce to Salesforce Mashup - 100% Apex

Screen 2: Here you can see the results of the first query, as well as my entries in the "update" section.  I’m using the data I received from my query to determine which records to update.

Salesforce to Salesforce Mashup - 100% Apex

Screen 3: And you can see here where "GenePoint" the company I select based on the ID has moved from "345 Shoreline Park" to "123 Reid Updated Blvd." (Class A digs if they ever existed.)

Salesforce to Salesforce 100% Apex Mashup

The Basic Process

1. Create a stub in the org that will provide the data.  This should be a global webservice class.  Save the generated WSDL for this class.

2. Import that WSDL using WSDL2APEX in the org that will consume the data.  It will create a matching objects.

3. Create a utility method that handles authentication for you.  You won’t be able to use either the partner or enterprise WSDL in your Apex so you’ll need to roll your own.  We have a quick & dirty version below.

4. You’ll need a Visualforce page and a Visualforce controller to tie everything together.  Those are pretty trivial so I’ve left them out of this post (but they’re in the code, below).

The Code – Data Provider Org

Code is posted in a separate file.  Download it!

We started by creating a "DataProviderRequest" Apex Webservice class that executes queries and returns data.

Next was the Data Consumer. Note that this has both a "getSobjectData" and an "updateSobjectData" section. 

Code contains working examples of:

* Dynamic SOQL / Dynamic Object Udpates

* Login to one SFDC org from another.

Lessons Learned

* You need to create your own intermediate data type to move content back and forth between the orgs.  If you use SObject, you’ll have a schema which includes all of the SObject sub-types.  Not very useful (and just too long).

* Performance is reasonably good although not perfect.  Caching the session ID rather than logging in every time would improve performance.

* This is a reasonably good alternative to traditional integration methods but IMHO I would generally rather use things like Salesforce to Salesforce if the use case supports it.

* Getting this to production ready will require some tweaking but my over all thought is that it shouldn’t be too hard.

 

 

 

 

 

Chicago User Group Notes: FreshDM, Dreamforce and Verizon Wireless - December 18, 2008 at 4:35 pm

Just finished up at the Chicago User Group.  Pretty good crew showed up despite the weather and the time of year.  The particular one was hosted by Click Commerce and sponsored by Allegro and Model Metrics.
 
Who is Allegro?  Fair question.  They produce FreshDM, an on-demand direct marketing print fulfillment thing.  (There’s a catchier phrase for it — I just can’t find it right now.)  You know all those hours you’ve spent on postcard addressing?  Or letters?  Or whatever?  They take that process and make it point and click.  Put in your direct mail piece template, select the recipients and they do the rest: print, address, stamp, mail.  
 
One word: AWESOME!
 
If I think back a few years to when I would design a postcard and ship it out to PrintingForLess.com (who, by the way, still rocks) (I think, I haven’t used them in a few years), wait for the results to ship to me, print out a bunch of labels, peel and stick and run it through the postage machine OR WORSE apply stamps — you get the idea.  What a waste of time that was.
 
FreshDM — if you read this — feel free to set me up with a sample account so I can try it out on my Christmas cards.  You would make my day!
 
OK enough of a non-too-subtle plea for help getting Christmas cards done — back to CUG.  
 
We talked about Winter 09.  Standard stuff.  It’s funny — no one is talking about Visualforce Email templates which I LOVE.  Think about it — the ability to create an attachment that’s either CSV or PDF and send the whole thing out.  It’s AWESOME.  Not that the rest of the release isn’t — but I’d like to see more people talk about it for sure.
 
Then we had a chance to talk about some of the Model Metrics neatness — Lasso2Go mostly.  Ever notice that your Verizon wireless card sloooooooows down when you’re in front of a crowd?  Mine certainly did this time.  Ah the many joys of live demos!
 
But we had a good number of questions (not soft balls — actual questions) about how to work with Force.com sites and Amazon Web Services — enough that I don’t think too many people other than me noticed the slow wireless.  I took pictures of cards with my web cam, everything was transcribed in pretty near real time and we had what were I think a couple of pretty legitimate ooh’s and ah’s.
 
Thanks to Cecile and Denise for organizing everyone and for inviting us.  I look forward to the next one!

Force.com Sites, Visualforce & Your Mobile Device - December 15, 2008 at 5:57 pm

Note – Screen shots for Blackberry and iPhone below.

Dreamforce ’08 has come and gone.  We had a couple of nice mentions — Lasso2Go of course but we also had the DFMobile application. Hit http://dfmobile.force.com from your mobile device if you’d like to see it.  It works on a Blackberry, a WAP/ simple XHTML compatible device or an iPhone.

The use case: you’re a Dreamforce 08 attendee and you want to find out about the event from your phone.  And if you’ve already registered on the Dreamforce portal, you can access the schedule you built there on your mobile device.  You can search partners and sessions, find out more information about the Foo Fighters and local watering holes, and a whole lot more.*

The basic system is pretty straightforward.  Some details:

  • The back end is the existing SFDC event registration system based on customer portal.
  • The DFMobile piece starts at a page that inspects the client and redirects to either the WAP / simple XHTML page or to the iPhone page based on the HTTP_ACCEPT environmental variable.
  • Both resulting pages use the same Apex controller and are based on Force.com Sites.  Sites lets users see public information — partners, sessions, local info — without authenticating.
  • Users have the ability to search partners and sessions based on some simple criterial.
  • Users also have the ability to login.  Once logged in, the user can see the schedule they originally created on the full web client.

There were a few other features that didn’t quite make it to production.  For example, we created a way to highlight the particular room a session was in on the iPhone client.  And to be clear, this is used a single image that the iPhone highlighted based on coordinates in the object.  The only reason it didn’t make it to production was the timing of go-live.

For the iPhone developers out there, this is using the CiUI library from CNET.  Over all, CiUI was pretty serviceable.  The only thing that came up occassionally was an odd timing issue related to how fast CiUI could respond to user input.  Sometimes, during testing, the javascript that replaces the body of a page would get out of synch with the results coming back from SFDC.  The page would then display without the decorative wrapper containing the header, footer and CSS.  Note: this apears to have only been an issue in artificial rapid fite tesing, not in production, and wasn’t an issue related to Force.com response times.

The biggest lesson learned? Getting the permissions aligned between the custom object, customer portal and Force.com sites takes a minute to get used to.  If something isn’t checked, your application will appear unresponsive.  If your app appears unresponsive, chances are good that it’s related to permissions.

A pretty exciting project all in all.

Blackberry Screenshots

Blackberry Main Screen (WAP/Simple XHTML)

Blackberry Session Search Form

 

Blackberry Session Search Results

 iPhone Splash Screen

iPhone Main Menu

iPhone, post login, My Sessions > Tuesday view

* OK, well, not a whole lot more, but some more.  Check it out on the

Galorath: 80% Reduction In Development Effort with Force.com - November 15, 2008 at 9:22 am

So Dan Galorath has noticed Force.com and started to quantify the savings he believes users can achieve with it.  It looks like Marc Benioff sent the results around to all of SFDC.  With good reason – Galorath estimates 30-40% lower costs when compared to Java.

Very cool.  And consistent with my experience. 

In an explanatory article, How Galorath Quantified the Salesforce.com Platform, there are a couple of interesting nuggets hidden all the way at the bottom:

"For applications that are consistent with the built in capabilities of the SalesForce.com Platform, there appears to be about an 80% reduction in the actual development effort. Because of the ability to create with point-and-click operations to support prototyping, the requirements and design effort is reduced with estimates ranging from 10% to 25%."

You read that right: 80% reduction in development effort.  Wow.

And, since I’m a nitpicker, I’m going to pick on one thing.  Galorath writes:

"APEX does not provide UI services or support external web service calls, the primary focus is to provide data oriented transactional services – more like Stored Procedures in Oracle or SQL Server."

The web services call issue is just incorrect.  APEX absolutely supports those.  And the UI services section — I think this is splitting hairs.  APEX doesn’t, but Visualforce does.

Oh and since I’m really a nitpicker, it’s not "SalesForce.com" with a capital "F".  It’s lower case.  C’mon people.

Glad to see Force.com getting some good formal attention.  Now if we could just get some Z notation animators for it.