Salesforce has a pretty nice feature called "Bounced Email Alerts" which can be configured using the declaritive setup menu in Salesforce. This allows emails which were bounced when being sent via Salesforce to popup alerts on the Email address field in the standard pages. It's pretty useful, especially if your sending emails via Salesforce.
Take a look at the email alert and prompt below for what it looks like.
And if a user clicks on the alert it gives them some details:
But many users have other 3rd party systems which sends the email. So the question is how do I get the "Bounced Email Alerts" in Salesforce if I'm using another system to send the emails?
The answer is you can use Apex code. It actually very simple but not documented anywhere that I saw. There are two fields on the Contact object which trigger the Email Bounce Alert functionality. They are EmailBouncedDate and EmailBounceReason. If you populate these two fields on a Contact record, the Email Bounce Alert functionality will fire. And vice versa, if you null out those two fields the alerts go away.
These fields are only visible in Apex code. You can't create a workflow rule / field update to do this unfortunately. Luckily, the Apex code is pretty simple. For example, below I added a boolean flag to Contact call "Invalid Email". Whenever I update this field, be it from the UI or a Web Service call from a 3rd party email system, the Bounce Alert functionality fires.
Sample Code to set the Email Bounced Alerts in Apex:
trigger ContactTrigger on Contact (after delete, after insert, after undelete,
after update, before delete, before insert, before update)
{
if(Trigger.isBefore)
{
for(Contact contact : trigger.new)
{
if(contact.EmailBouncedDate == null && contact.EmailBouncedReason == null && contact.Invalid_Email__c == true)
{
contact.EmailBouncedDate = DateTime.now();
contact.EmailBouncedReason = 'Invalid Email Address Set By User';
}
if(contact.Invalid_Email__c == false)
{
contact.EmailBouncedDate = null;
contact.EmailBouncedReason = null;
}
}
}
}
In conclusion, if you have a 3rd party email system with Salesforce but still want to use the Bounced Email Alert functionality, you can do it if you have Enterprise or Unlimited Editions' of Salesforce.
Lessons learned and technical ramblings from 15 years in the exciting field of Information Technology, and specifically Software Development. Strong emphasis on Platform as a Service and Salesforce Platform for enterprise software development.
Stat Tracker
Monday, May 16, 2011
Monday, May 2, 2011
Chicago Bus Radar - Builing a Force.com HTML 5 Application with Geo Location and Third Party API's
Chicago Bus Radar
For the past few weeks during my spare time I've been doing some work with the CTA (Chicago Transit Authority) API. For those who don't live in Chicago, the CTA manages all of Chicago's bus's and trains. About two years ago they upgraded all their bus's with a pretty sweet GPS system, as well as a Website for getting estimated arrival times (www.ctabustracker.com). Literally this was life changing for me when it was released. I rely exclusively on CTA for my transportation since I live in the city, and the ability to see bus times in real-time has saved me so much time.
My only problem with the default CTA Website is that its dumb when it comes to being location-aware. If I want to get the bus time for a stop I'm at, I have to either bookmark the exact bus stop into my browser on my iPhone, or I have to text message the CTA with the Stop ID.
The other problem I have is that its not very good for doing comparative analysis of bus stops. For example, I live in between two different sets of bus stops. Both of these have routes which go downtown. Based on which bus arrives at a stop first, I can take either one to get downtown where I need to go. But I don't have a way to see one view of both the bus stops in the default CTA application.
Fortunately for me, the CTA released an API so that anyone who want to can access all the bus arrival time information. I just had to sign up and the CTA granted me API access. With the API Access I was able to quickly build an application which could do this. It is located at http://www.chicagobusradar.com. If you don't live in Chicago you won't get any buses naturally, so you can take a look at the screenshot below.
A few of the highlights:
1. HTML 5 GeoLocation functionality for cross platform compliance (iPhone, Android, etc)
2. Force.com is the platform which runs the application database and web pages, controller code, etc.
3. CTA API HTTP calls to retrieve the bus estimate arrival times from CTA System.
I'm still working on tweaking it some more, but right now its got 3,000 stops in the system which is about 1/4 of all the routes in Chicago. I still need to cache the rest of the Route's, as well as build an HTML 5 Manifest file for some nice icons on iPhone / Android devices.
I also need to add some filtering capabilities, differentiate colors on the Google Map, and a few more UI tweaks. But the major pieces are all in place at least.
Eventually I'll be posting the code sample somewhere, so if your interested in using Force.com to build HTML5 / Geo-Location based application you'll be able to pull the code as a reference.
Stay tuned, and peace out!
For the past few weeks during my spare time I've been doing some work with the CTA (Chicago Transit Authority) API. For those who don't live in Chicago, the CTA manages all of Chicago's bus's and trains. About two years ago they upgraded all their bus's with a pretty sweet GPS system, as well as a Website for getting estimated arrival times (www.ctabustracker.com). Literally this was life changing for me when it was released. I rely exclusively on CTA for my transportation since I live in the city, and the ability to see bus times in real-time has saved me so much time.
My only problem with the default CTA Website is that its dumb when it comes to being location-aware. If I want to get the bus time for a stop I'm at, I have to either bookmark the exact bus stop into my browser on my iPhone, or I have to text message the CTA with the Stop ID.
The other problem I have is that its not very good for doing comparative analysis of bus stops. For example, I live in between two different sets of bus stops. Both of these have routes which go downtown. Based on which bus arrives at a stop first, I can take either one to get downtown where I need to go. But I don't have a way to see one view of both the bus stops in the default CTA application.
Fortunately for me, the CTA released an API so that anyone who want to can access all the bus arrival time information. I just had to sign up and the CTA granted me API access. With the API Access I was able to quickly build an application which could do this. It is located at http://www.chicagobusradar.com. If you don't live in Chicago you won't get any buses naturally, so you can take a look at the screenshot below.
A few of the highlights:
1. HTML 5 GeoLocation functionality for cross platform compliance (iPhone, Android, etc)
2. Force.com is the platform which runs the application database and web pages, controller code, etc.
3. CTA API HTTP calls to retrieve the bus estimate arrival times from CTA System.
I'm still working on tweaking it some more, but right now its got 3,000 stops in the system which is about 1/4 of all the routes in Chicago. I still need to cache the rest of the Route's, as well as build an HTML 5 Manifest file for some nice icons on iPhone / Android devices.
I also need to add some filtering capabilities, differentiate colors on the Google Map, and a few more UI tweaks. But the major pieces are all in place at least.
Eventually I'll be posting the code sample somewhere, so if your interested in using Force.com to build HTML5 / Geo-Location based application you'll be able to pull the code as a reference.
Stay tuned, and peace out!
Thursday, April 7, 2011
Visualforce Inline Editing - IE Error - Fix
Salesforce released inline editing in Spring 11 for Visualforce pages, which is pretty sweet. Especially considering when you need to replace a standard detail page with a VF page to do some secret sauce awesomeness, this was one feature which roadblocked it many times. It couldn't be simpler to implement, for example:
<apex:page standardController="CustomObjectABC__c" extensions="SecretSauceController" >
<apex:form>
<apex:detail inlineedit="true">
</apex:detail>
<apex:pageBlock title="Secret Sauce Functionality!!!!" >
<apex:pageBlockButtons >
<apex:commandButton value="Execute The Awesome" action="{!awesomeMethod}" rendered="{!isUserAwesome}"/>
</apex:pageBlockButtons>
<apex:outputText value={!howAwesomeIsUser}/>
</apex:pageBlock>
<apex:form>
</apex:page>
So whats the problem? Nothing if you use a decent browser like Firefox or Chrome.
But what about IE?
Well, if you have some <apex:commandButton>'s on the page, the buttons won't work and you will get a javascript error like this:
IE Mesage: 'document.forms.echoScontrolForm_066700000004hqK' is null or not an object
And now your custom code won't execute! Yeah, this frustrated me big time, but I found a work around by playing around with the page for about an hour. The issue is how Force.com platform is handling the forms. If you wrap each piece in its own <apex:form> with their own ids your good. So using the above example, if you do this it will work:
<apex:page standardController="CustomObjectABC__c" extensions="SecretSauceController" >
<apex:form id="detailForm1">
<apex:detail inlineedit="true">
</apex:detail>
</apex:form>
<apex:form id="detailForm2">
<apex:pageBlock title="Secret Sauce Functionality!!!!" >
<apex:pageBlockButtons >
<apex:commandButton value="Execute The Awesome" action="{!awesomeMethod}" rendered="{!isUserAwesome}"/>
</apex:pageBlockButtons>
<apex:outputText value={!howAwesomeIsUser}/>
</apex:pageBlock>
<apex:form>
</apex:page>
It should be noted that this is a known issue and that Salesforce is working on a fix that is scheduled to be released in the upcoming Summer 11 release. Until then, if you can't wait for inline editing (and why would you?) you can use the above fix.
I mean basically I hope the goal is to give VF all the feature of standard detail pages. Its still not quite there yet, some things you just can't get. But they are getting there.
Man, all this secret sauce code has me craving a Big Mac...... MMMMMM.......Heart Attackalicious.....
http://boards.developerforce.com/t5/Visualforce-Development/lt-apex-form-gt-tag-and-inline-editing-break-googlemaps-packaged/m-p/265569#M34264
<apex:page standardController="CustomObjectABC__c" extensions="SecretSauceController" >
<apex:form>
<apex:detail inlineedit="true">
</apex:detail>
<apex:pageBlock title="Secret Sauce Functionality!!!!" >
<apex:pageBlockButtons >
<apex:commandButton value="Execute The Awesome" action="{!awesomeMethod}" rendered="{!isUserAwesome}"/>
</apex:pageBlockButtons>
<apex:outputText value={!howAwesomeIsUser}/>
</apex:pageBlock>
<apex:form>
</apex:page>
So whats the problem? Nothing if you use a decent browser like Firefox or Chrome.
But what about IE?
Well, if you have some <apex:commandButton>'s on the page, the buttons won't work and you will get a javascript error like this:
IE Mesage: 'document.forms.echoScontrolForm_066700000004hqK' is null or not an object
And now your custom code won't execute! Yeah, this frustrated me big time, but I found a work around by playing around with the page for about an hour. The issue is how Force.com platform is handling the forms. If you wrap each piece in its own <apex:form> with their own ids your good. So using the above example, if you do this it will work:
<apex:page standardController="CustomObjectABC__c" extensions="SecretSauceController" >
<apex:form id="detailForm1">
<apex:detail inlineedit="true">
</apex:detail>
</apex:form>
<apex:form id="detailForm2">
<apex:pageBlock title="Secret Sauce Functionality!!!!" >
<apex:pageBlockButtons >
<apex:commandButton value="Execute The Awesome" action="{!awesomeMethod}" rendered="{!isUserAwesome}"/>
</apex:pageBlockButtons>
<apex:outputText value={!howAwesomeIsUser}/>
</apex:pageBlock>
<apex:form>
</apex:page>
It should be noted that this is a known issue and that Salesforce is working on a fix that is scheduled to be released in the upcoming Summer 11 release. Until then, if you can't wait for inline editing (and why would you?) you can use the above fix.
I mean basically I hope the goal is to give VF all the feature of standard detail pages. Its still not quite there yet, some things you just can't get. But they are getting there.
Man, all this secret sauce code has me craving a Big Mac...... MMMMMM.......Heart Attackalicious.....
http://boards.developerforce.com/t5/Visualforce-Development/lt-apex-form-gt-tag-and-inline-editing-break-googlemaps-packaged/m-p/265569#M34264
Subscribe to:
Posts (Atom)


