Tuesday 31 May 2011

Calculating Age From Date of Birth

Recently I got inspired from one of my favorite technical article spot (http://forceguru.blogspot.com/2011/05/calculating-age-from-birth-date.html) for calculating Age of from Date of Birth. Here I have added some flexibility for getting age up to month Level just copy and paste following code in your formula field  (which should be of number type).of years
**********************************************************************************

If(
   OR(
      And(
           MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
     ),
      And(
  MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
         )
      ),
         (YEAR(TODAY())-YEAR(DOB_API)),
         If(
            OR(
               And(
                   MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
                  ),
               And(
                  MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
                  )
              ),
         (YEAR(TODAY())-YEAR(DOB_API )-1),
0
           )
)


**********************************************************************************
and for months copy and paste following code in your formula field (which should be of number type).of months.
**********************************************************************************


If(
   OR(
      And(
           MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
      ),
      And(
   MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
         )
      ),
        MONTH(TODAY())-MONTH(DOB_API) ,
         If(
            OR(
               And(
                   MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
                  ),
               And(
                  MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
                  )
              ),
        (12-MONTH(DOB_API ))+MONTH(TODAY()) ,
0
           )
)

**********************************************************************************
Here You will get Age in years like if your DOB is 5/8/1990 then Today(31/5/2011) then your age would be 20 years 9 months.

I would like to refer great thanks and whole credit to Mr. Ankit Arora dropping focus on this topic.
Source : http://forceguru.blogspot.com/2011/05/calculating-age-from-birth-date.html

Friday 27 May 2011

How to Use Field Set in VF page

Problem :-  We have to show some fields on VF Page and can add/remove fields on page at run time without making any change in VF page code.
Solution :- So here we can go through step by step.
Step1):-
             follow by clicking in sandBox org. on User's Name>Setup>customize>Account(any standard Object)>field set.
Step2.):-
           Create New field Set According to requirement.
(One thing should keep in mind once you create Available list in field Set then after making package you can not change it)
Step3.):-
           Create your VF page(Here I am mentioning one Sample Code)

VF Page code:-



    
       
           
               
                             
       
        
                           
           
    
Screen Shot:-




Here I have included 4 fields of Account Sobject if I want to add/remove some fileds I can easily do this just by changing in field Set (not need to change in VF page).we can use field set for custom object also.




Wednesday 18 May 2011

How to show Accounts List (in Different views ) on DashBoard

Solution :- step1- Create Vf Page(page coding is given below).
  



    
        
        
            
            
            
        
       
    
    
    
        
        {!a.name}
        
    



step 2 go to DashBoard Simply click on DashBoard Tab and then click on List of DashBoards Create or Edit any Dash Board then goto Data sources and select Vf page which you have Created above. step3. Now you are able to look name of Accounts in following views on DashBoard
        A)My Accounts
        B)Accounts are Created/Modified in recent week
        C)Recently viewed Accounts
        D)All Accounts

Wednesday 11 May 2011

Use Date Picker while header & sidebar should not be visible

Problem : when we make showHeader false then We cannot use Date-picker
so we can use following two methods:
1.First approach Use inline=1 in Url(of VF page at run time ) at last
 2. Second Approach Use JavaScript to hide Header and Side Bar without making these false
 Visual Page Code:
  


    

    
     Your Date Birth :