Skip to main content

Posts

Showing posts from December, 2014

How to add Salesforce Chatter Information in Visualforce Page??

Adding chatter functionality in to visualforce is quite simple. Use below tags. <chatter:feed>: Displays the Chatter feed for a record. <chatter:feedWithFollowers>: An integrated UI component that displays the Chatter feed for a record, its list of followers, and optionally, a header bar that allows users to show or hide the Chatter feed and subscribe to it. <chatter:follow>: Renders a button for a user to follow or unfollow a Chatter record. <chatter:followers>: Displays the list of Chatter followers for a record. <chatter:feed entityId="{!Leadid}" /> <chatter:follow entityId="{!Leadid}" /> <chatter:followers entityId="{!Leadid}" /> Id LeadId =  ApexPages.currentPage().getParameters().get('id');

Phone Validation For USA format.

Hi  We all know USA phone number "(999) 999-9999" . How do we restrict user from invalid entry ? We can create validation rule. Error Condition Formula:- NOT(REGEX(Phone__c, "^\\(\\d{3}\\)\\s?\\d{3}-\\d{4}")) Error Message:- US phone numbers should be in this format: (999) 999-9999. if you want to add validation in controller, below is the method public static boolean isValid(String phone){                       String PhoneRegex =  ' ^\\(\\d{3}\\)\\s?\\d{3}-\\d{4} ';                  Pattern MyPattern = Pattern.compile(PhoneRegex);                  // then instantiate a new Matcher object “MyMatcher”         Matcher MyMatcher = MyPattern.matcher(phone);         if (!MyMatcher.matches()) {         return false;        ...

How to refer custom html page from document in visualforce page.

Hi All,  I came across one requirement during work, thought to share, it will be useful info for you. I was working on designing partner portal site for user,as you all know for designing site,we have to take care of company branding, header and footer and lot more style sheet and css, and it's not a best practice to use all the code in vf page itself ,because same header and footer might be required to be used in several pages,so it's better we will keep it separately whenever it is required we can refer it. We have stored header and footer code(html page with css) in document object in sfdc.Now the question is how can we refer it in vf page? If we have stored in static resource it is quite simple to refer it.(use global variable $Resource). Solution:- Use Below code to refer this.     public String getHeader() {                  return [Select Body,Name From Document Where Name  = 'Header'].Body.toString(); ...