Sunday, February 15, 2015

Validations Rules.................................

=============VR====================
ISCHANGED(Aadhar_Card__c),
IF(ISPICKVAL(Aadhar_Card__c ,"Yes"),

OR(ISBLANK(Aadhar_Card_No__c),LEN(TRIM(Aadhar_Card_No__c) )<> 12) , NOT(ISBLANK(Aadhar_Card_No__c)))

Error::1) Please enter Aadhar card No.
2) Please Enter Valid Aadhar card No.
3) If 'Aadhar card No.' is entered then select 'Aadhar card' as 'yes'.

=======================================
ISPICKVAL(Aadhar_Card__c,"Yes") &&
ISBLANK(Aadhar_Card_No__c)

Error::Please enter Aadhar Card No

======================================
ISCHANGED( Name )

Error::You are not allowed to change the Client Name
=========================================
CONTAINS( TRIM(Full_Present_Address__c) , "|"))

Error::Address should not contain "|" symbol

===========================================
OR
(
Age1__c < 21,
Age1__c > 58
)

Error::Age of primary customer should be between 21 - 58 years

================================================
OR(AND( ISNEW() || ISCHANGED(Address_Proof__c) ,ISPICKVAL( Address_Proof__c , "Bank Passbook"),AND(LEN( Address_Proof_No__c )>18,NOT(REGEX( Address_Proof_No__c , "(\\d{18})?")))
),
),
    (AND
        (ISPICKVAL( Address_Proof__c , "Bank Passbook") , ISBLANK( Address_Proof_No__c))
    )
  )

  Error::Pass book number should be alphanumeric and cannot be greater than 18 digits.
 
 

Sunday, February 1, 2015

How To Use the Apex:tabPanel In visualforce page

The Following attributes mandatory  for using tabPanel.

1.switchType="client"     value="{!CurrentTab}"
2.Here currentTab shows presentTab when you moving one tab to another tab.
3.<apex:tab/> attribute  name="Tab"[used for development],shows current tab name.and label shows the UI.



Default Tab is Account and when your click on Next button it will goes to account1 tab.

==============VISUALFORCE PAGE====================
<apex:page controller="tabpanelclass" showHeader="false">
   <apex:form >
    <apex:pageMessages id="errMsg" />
     <apex:tabPanel switchType="client" value="{!CurrentTab}" id="tabpanel">
        <apex:tab name="Tab" label="Account" labelWidth="200px" style="color:blue;font size:10px">
          <apex:pageBlock >
            <apex:pageBlockButtons >
              <apex:commandButton value="Next" action="{!tabMethod}" reRender="tabpanel,errMsg">
                <apex:param name="tabNext" value="Tab1"/>
              </apex:commandButton>
            </apex:pageBlockButtons>
          </apex:pageBlock>
        </apex:tab>
        <apex:tab name="Tab1" label="Account1" labelWidth="200px" >
            <apex:pageBlock >
            <apex:pageBlockButtons >
              <apex:commandButton value="Next" action="{!tabMethod1}" reRender="tabpanel">
                  <apex:param name="tabNext" value="Tab2"/>
              </apex:commandButton>
              <apex:commandButton value="Previous" action="{!tabMethod}" reRender="tabpanel">
                <apex:param name="tabNext" value="Tab"/>
              </apex:commandButton>
            </apex:pageBlockButtons>
          </apex:pageBlock>
        </apex:tab>
        <apex:tab name="Tab2" label="Account2" labelWidth="200px" >
          <apex:pageBlock >
            <apex:pageBlockButtons >
              <apex:commandButton value="Next" action="{!tabMethod2}" reRender="tabpanel">
                  <apex:param name="tabNext" value="Tab3"/>
              </apex:commandButton>
              <apex:commandButton value="Previous" action="{!tabMethod1}" reRender="tabpanel">
                  <apex:param name="tabNext" value="Tab1"/>
              </apex:commandButton>
            </apex:pageBlockButtons>
          </apex:pageBlock>
        </apex:tab>
        <apex:tab name="Tab3" label="Account3" labelWidth="200px" >
           <apex:pageBlock >
            <apex:pageBlockButtons >
              <apex:commandButton value="Next" action="{!tabMethod3}" reRender="tabpanel">
                 <apex:param name="tabNext" value="Tab4"/>
              </apex:commandButton>
              <apex:commandButton value="Previous" action="{!tabMethod2}" reRender="tabpanel">
                 <apex:param name="tabNext" value="Tab2"/>
              </apex:commandButton>
            </apex:pageBlockButtons>
          </apex:pageBlock>
        </apex:tab>
        <apex:tab name="Tab4" label="Account4" labelWidth="200px" >
           <apex:pageBlock >
            <apex:pageBlockButtons >
              <apex:commandButton value="Next" action="{!tabMethod4}" reRender="tabpanel">
                 <apex:param name="tabNext" value="Tab"/>
              </apex:commandButton>
              <apex:commandButton value="Previous" action="{!tabMethod3}" reRender="tabpanel">
                 <apex:param name="tabNext" value="Tab3"/>
              </apex:commandButton>
            </apex:pageBlockButtons>
          </apex:pageBlock>
        </apex:tab>
     </apex:tabPanel>
   </apex:form>
</apex:page>
=======================CONTROLLER==========================
public class tabpanelclass {

    public PageReference tabMethod4() {
        nextTabValue = Apexpages.currentPage().getParameters().get('tabNext');
        system.debug('@@@@@@@@@@@'+nextTabValue);
        CurrentTab=nextTabValue;
        return null;
    }


    public PageReference tabMethod3() {
        nextTabValue = Apexpages.currentPage().getParameters().get('tabNext');
        system.debug('@@@@@@@@@@@'+nextTabValue);
        CurrentTab=nextTabValue;
        return null;
    }


    public PageReference tabMethod2() {
        nextTabValue = Apexpages.currentPage().getParameters().get('tabNext');
        system.debug('@@@@@@@@@@@'+nextTabValue);
        CurrentTab=nextTabValue;
        return null;
    }


    public PageReference tabMethod1() {
        nextTabValue = Apexpages.currentPage().getParameters().get('tabNext');
        system.debug('@@@@@@@@@@@'+nextTabValue);
        CurrentTab=nextTabValue;
        return null;
    }


    public PageReference tabMethod() {
       nextTabValue = Apexpages.currentPage().getParameters().get('tabNext');
       system.debug('@@@@@@@@@@@'+nextTabValue);
        if(count>2)
       CurrentTab=nextTabValue;
      else{
        ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Hai Ashok');
       ApexPages.addMessage(msg);
      }
       return null;
    }

    public integer count=1;
    public String CurrentTab { get; set; }
    public String nextTabValue{get;set;}
    public tabpanelclass(){
      CurrentTab='Tab';// IT SHWOS DEFAULT TAB NAME
    }
}