Oh my god. It's full of code!

Salesforce outbound messages and visualforce

So I’ve been working on a project recently. A crazy one. One I hope to be able to package and sell on the app exchange.

What I am doing, is attempting to create a Salesforce application that will be packagable and sellable in the appexchange market. The challenge I am facing is allowing an end user to select when an apex class will be invoked, and pass their own data to it. I don’t know if a user will want to call a class when a contact is created, or a lead is updated, or an opportunity is deleted. The application is simply used for sending text (SMS) messages, based on criteria the user sets. The good news is that my application is pretty much done, save for one step. The bad news, that one step may be impossible, at least how I am trying to accomplish it.

My first thought on how to accomplish this was use a workflow rule (since workflow rules are easy enough for even regular end users to create) to send an outbound message to a visualforce page that comes with the app. The visualforce page would receive the SOAP data (which lives in the http request data), parse it out and send the data contained within to an apex class, which does the rest of the hard work of actually sending the message. The problem here is that, as far as I know, visualforce/apex have no way to access the data contained within the http request. Hence the SOAP data that is passed is useless, it is lost.

The workflow as I see it

The key thing is here, is that I simply need an easy way for users to select when the apex class will be called, and what data they will pass to it (it only needs the phone number and the message). I don’t really care how it happens as long as it is easy for the user to set up.

If this will not work, I only have two other ideas. One is to make the workflow rule send an email to a designated email address that has a bot monitoring the inbox, which checks the mailbox every few seconds, reads the emails, extracts the message data (the email would probably have XML in the body) then with that information call the apex method that sends the message. The other approach is to have the outbound messages go to a webservice that my company controls on premise, which COULD access the SOAP data in http request, parse it out, then call a visualforce page associated with the target account and pass the message and phone in the URL as arguments.

I have just emailed a Salesforce engineer that I met recently and maybe he’ll be able to come up with a way to doing what I want to accomplish. Otherwise, if you have any awesome ideas, feel free to leave them in the comments. I’ll give a free copy of the app to anyone who can solve this last problem.

6 responses

  1. Pingback: Tweets that mention Salesforce outbound messages and visualforce « I Write Crappy Code -- Topsy.com

  2. Very good blog post. I certainly appreciate this website.
    Keep writing!

    October 23, 2012 at 5:16 pm

  3. How do you receive an outbound message in Salesforce? A webservice method?? I’m treying to do this exact same thing, except not involving a VisualForce page… just a workflow rule that sends an outbound messgae, and then a webservice method that receives this outbound message and performs some action (doing this to make external callout which can’t be done through trigger 😦 )

    February 16, 2013 at 9:14 pm

    • You can do external callouts in triggers. you should wrap method with @future annotation then it’s possible to call it from trigger.

      July 18, 2013 at 1:07 pm

  4. Admiring the persistence you put into your

    site and in depth information you present.
    It’s good to come

    across a blog every once in a while that isn’t the same unwanted rehashed material.
    Excellent read! I’ve bookmarked your site and I’m including your

    RSS feeds to my Google account.

    April 24, 2013 at 10:32 pm

  5. 1st tip- don’t make use of а mug plunger for the bathroom!

    August 15, 2013 at 8:47 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s