October 2012

Salesforce

Regular Expression for email validation using Apex in Salesforce

Sample Regular Expression for email validation using Apex is given below Sample Code:                                  if(Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}', email))                {                    //success                }                else                {                    ....

Salesforce

Email validation using Apex in Salesforce

Visualforce page: <apex:page controller="testController">    <apex:form id="myform">    <apex:pagemessages />    <apex:pageBlock id="myblock">        Email Address: <apex:inputText value="{!email}" id="email"/><br/><br/>        <apex:commandButton value="Click me!" action="{!checkEmail}"/>    </apex:pageBlock>    </apex:form></apex:page> Apex Code: public class testController{    public String email { ....

Salesforce

Calling Apex method from a Custom Button

To call Apex method from Custom Button, follow the below steps 1. Create a custom button and enter the following code Syntax: {!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/12.0/apex.js")} sforce.apex.execute("Class_Name","Method_Name",{parameter_Name:"value"}); location.reload(true); Code: {!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} var ....