MK Partners Archive for March, 2009

Converting Strings to Integers with Apex

For one of our projects, we need to pass an integer to a function. Unfortunately, the integer is stored in a text field that is manually populated by the user. This means that it’s possible that some letters or other characters get put in the field in addition to the number we’re interested in. We know that you can do this with a regular expression but that’s kinda complex and above the heads of most of our readers. So here’s a simple way to do it via Apex that everyone should be able to follow:

Set<String> validChars = new Set<String>{'0','1','2','3','4','5','6','7','8','9'};
String mixedText = '123xyz';
String numbersOnly = '';
for (Integer i=0; i<mixedText.length(); i++)
{
    if ( validChars.contains( mixedText.substring(i,i+1)) )
    {
        numbersOnly += mixedText.substring(i,i+1);
    }
}

Going Mobile

We wanted to write about two recent changes we’ve made in our mobile configuration.

Last year we wrote about syncing our data from salesforce.com to Google Apps to a windows mobile device. Back then, we were using a great service called Nuevasync.com to sync over the air with the windows mobile device. Well Google recently rolled out this functionality themselves to sync events and contacts.

We started using this service a week after it came out and haven’t looked back. Google is running the exaxct same MS Exchange technology as NuevaSync, but since it’s native Google there is no need for a token authorizing access. Other than a brief glitch the morning after the switch, which was quickly repaired upon resync, we haven’t noticed any problems.

Earlier this week, salesforce.com announced that Mobile Lite functionality is included free with all licenses. This is a nice looking add-on that lets you have read only access to your data from your mobile device. Since we already sync our contacts with our phones (via google as mentioned above), this really doesn’t add much functionality for our day-to-day operations. But, should our sync ever break or should we ever need information from an opportunity or another object, this tool will be a lifesaver.

If we know salesforce.com (and we do), we think that this is a way to get userse hooked on using mobile functionality so that they eventually purchase full mobile licenses. It also goes without saying, that the more ways a company uses salesforce, the less chance of them ever canceling their licenses. It’s definitely worked on us.

New AppExchange powered by Salesforce Sites

You may have already heard the announcement that salesforce.com is now running its AppExchange site using salesforce sites. This means all the content on the site is hosted within salesforce.com and rendered as publicly facing VisualForce pages. Sites is currently still in developer pilot and is not generally available yet but key customers have been granted its use in their production orgs. Pricing is based on page views with a base number included with your licenses.

In case you wanted to see what it looks like when you go over the number of page views included in your licensing, check out this screenshot of what AppExchange.com looked like today.

AppExchange.com goes down

AppExchange.com goes down