Showing posts with label Viualforce. Show all posts
Showing posts with label Viualforce. Show all posts

Monday 30 September 2013

REGEX in Salesforce

13:00
What is a RegEx?

Regular Expression in computing terms is a pattern that is used to search. It has its own syntax and semantics. To learn more on what RegEx is visit --> here
Great now we learnt what REGEX is, to build your own regex visit --> buildregex.com

So how does all this play in salesforce apex ? There are numerous use cases for using regex and checking patterns e.g. Checking if string is in Email Format.

There are 2 Major Classes to check if regex matches. Pattern Class and Matcher Class
in short, the pattern class is used to store a type of regex and once you have a pattern stored, We use the Matcher Class to identify if a specified string matches the pattern.

Here's the code for Matching String to Email pattern In salesforce

public static Boolean checkEmailFormat(String email) {
        String emailRegEx = '[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\*\\/\\=\\?\\^\\_\\+\\-\\`\\{\\|\\}\\~\'._%+-]+@[a-zA-Z0-9\\-.-]+\\.[a-zA-Z]+';
        Pattern MyPattern = Pattern.compile(emailRegex);
        Matcher MyMatcher = MyPattern.matcher(email);
        Boolean result = MyMatcher.matches();
        return result;
    }

This is a self explanatory code, the Pattern is first compiled and stored, then we check the "email" parameter matches the regex, the result (true/false) is returned to the calling method. Wanna learn more ? --> Check SFDC Documentation

Hope this helped  ! Let me know your thoughts or if there are some neat regex that you'd like to share in the comments . Happy Coding !

Wednesday 24 April 2013

How to activate Summer ’13 Preview on sandbox

10:18
Summer 13The salesforce.com Summer ‘13 release is quickly approaching and soon you'll be able to take advantage of exciting new features and functionality! If you are a Force.com Sandbox customer, you have the opportunity to get early access to Summer ‘13 in your Sandbox and test new customization and features (the chance to get your feet wet) before your production organization is upgraded.




Wednesday 23 January 2013

Reload Standard Detail page from Inline VF

07:58
 
visualforceI just faced a small block, Pretty simple once you've figured it out, Thought of sharing it and saving time for us in the future. Most of the time we require to reload the Standard Page following an  action on the inline VF Page. The solution to this was not apparently available to me when I needed it. Usually after clicking on a link or button we need to refresh the standard (parent page) the VF page is in. Read more on how to add inline VF Pages

Problem: A VF page is inline on a standard detail Page, On click of button inside VF Page, Reload the standard Detail Page once action completes in the Inline VF page