Play Games

Search This Blog

Friday, October 17, 2014

Monday, September 15, 2014

Important Links

  http://forceguru.blogspot.in
  http://salesforceapexcodecorner.blogspot.in/
  http://forcejunky.blogspot.in/
  http://www.forcetree.com/
  http://www.sfdcpoint.com/
  http://www.sfdc99.com/#
  http://cloudyworlds.blogspot.in
  http://kperisetla.blogspot.in
  http://askforce.blogspot.in/
  http://www.salesforcehacker.com/2013/04/how-to-test-migrate-profiles-and.html
  http://www.tehnrd.com/batch-apex-status-bar/
  http://www.forcetree.com/2011/09/radiobutton-in-datatable-in-visualforce.htm

Thursday, September 4, 2014

OutofMemoryError: Java heap space Error

Problem : When creating a force.com project using eclipse,some times we get the "out of memory Java heap size error".
sometimes while deploying force.com project also,we get the same error.

Solution:
     
step 1:Go to the directory where eclipse executable file is present.










step 2: In the same directory we can see Eclipse.ini file (configuaration settings file).
Open the file in notepad and find the line -Xmx256m.Increase the memory by changing this line
For example -Xmx512m or -Xmx1024m etc.Then save the file and close it.
step 3:Restart Eclipse.

Wednesday, August 27, 2014

Display Salesforce Data in the form of Chart(pie chart,bar chart etc) in visualforce page

We can display salesforce data in the form of pie chart,bar chart etc in visualforce page.
Example
Apex Class:
global with sharing class GoogleChartsController {
    
    /**
      Loads most recent 10 Opportunities
    */
    @RemoteAction  
    global static Opportunity[] loadOpps() {
        return [select Id, Name, ExpectedRevenue, Amount from Opportunity order by CreatedDate DESC limit 10];
    }  

}

Visualforce Page :
<apex:page controller="GoogleChartsController" sidebar="false">
    <!-- Google API inclusion -->
    <apex:includeScript id="a" value="https://www.google.com/jsapi" />
    
    <apex:sectionHeader title="Google Charts + Javascript Remoting" subtitle="Demoing - Opportunities by Exepected Revenue"/>

    <!-- Google Charts will be drawn in this DIV -->
    <div id="chartBlock" />
    
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
      
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(initCharts);
  
        function initCharts() {        
          // Following the usual Remoting syntax
          // [<namespace>.]<controller>.<method>([params...,] <callbackFunction>(result, event) {...}
          // controller : GoogleChartsController
          // method : loadOpps
          GoogleChartsController.loadOpps(
                 function(result, event){ 
                     // load Column chart
                     var visualization = new google.visualization.ColumnChart(document.getElementById('chartBlock'));
                     // Prepare table model for chart with columns
                     var data = new google.visualization.DataTable();
                     data.addColumn('string', 'Opportunity');
                     data.addColumn('number', 'Expected Revenue');
                     data.addColumn('number', 'Amount');   
                     // add rows from the remoting results
                     for(var i =0; i<result.length;i++){
                        var r = result[i];
                        data.addRow([r.Name, r.ExpectedRevenue, r.Amount]);
                      }
                    // all done, lets draw the chart with some options to make it look nice.
                    visualization.draw(data, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:window.innerWidth,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
              }, {escape:true});
          }
    </script>
</apex:page>

Output:



SlideShow in Visualforce Page

<apex:page >
<html>
<script type="text/javascript">
var slideimages=new Array()
function slideshowimages()
{

     for (i=0;i<slideshowimages.arguments.length;i++){
         slideimages[i]=new Image()
         slideimages[i].src=slideshowimages.arguments[i]
    }
}
</script>

<img src="{!$Resource.image2}" alt="Slideshow Image Script" title="Slideshow Image Script" name="slide" border="0" width="200" height="200"/><a href="http://hscripts.com" style="text-decoration:none;cursor:pointer;font-size:12px;color:green;">H</a>
<script type="text/javascript">
slideshowimages("{!$Resource.image2}","{!$Resource.image1}")
var slideshowspeed=2000
var whichimage=0
function slideit()
{
     if (!document.images)
           return
     document.images.slide.src=slideimages[whichimage].src
     if (whichimage<slideimages.length-1)
              whichimage++
     else
              whichimage=0
      setTimeout("slideit()",slideshowspeed)
}
 slideit()
</script>
<!-- Script by hscripts.com -->
</html>
</apex:page>
Note: Replace image urls.


snow fall effect in visualforce page

Visualforce Page Code:

<apex:page showHeader="false" sidebar="false">
<html>
<script>
 /*   Free Script provided by HIOXINDIA            */
/*   visit us at http://www.hscripts.com     */
/*   This is a copyright product of hioxindia.com */

var image="{!$Resource.snowfall}";  //Image path should be given here
var no = 15; // No of images should fall
var time = 0; // Configure whether image should disappear after x seconds (0=never):
var speed = 70; // Fix how fast the image should fall
var i, dwidth = 900, dheight =500;
var nht = dheight;
var toppos = 0;

if(document.all){
    var ie4up = 1;
}else{
    var ie4up = 0;
}

if(document.getElementById && !document.all){
    var ns6up = 1;
}else{
    var ns6up = 0;
}

function getScrollXY() {
  var scrOfX = 10, scrOfY = 10;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY =window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
   scrOfY = document.documentElement.scrollTop;
   scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

var timer;

function ranrot()
{

var a = getScrollXY()
if(timer)
{
    clearTimeout(timer);
}
toppos = a[1];
dheight = nht+a[1];
//alert(dheight);

timer = setTimeout('ranrot()',2000);
}
   
ranrot();
   
function iecompattest()
{
    if(document.compatMode && document.compatMode!="BackCompat")
    {
        return document.documentElement;
    }else{
        return document.body;
    }
   
}
if (ns6up) {
    dwidth = window.innerWidth;
    dheight = window.innerHeight;
}
else if (ie4up) {
    dwidth = iecompattest().clientWidth;
    dheight = iecompattest().clientHeight;
}

nht = dheight;

var cv = new Array();
var px = new Array();       //position variables
var py = new Array();      //position variables
var am = new Array();     //amplitude variables
var sx = new Array();    //step variables
var sy = new Array();   //step variables

for (i = 0; i < no; ++ i) { 
    cv[i] = 0;
    px[i] = Math.random()*(dwidth-100);  // set position variables
    py[i] = Math.random()*dheight;     // set position variables
    am[i] = Math.random()*20;         // set amplitude variables
    sx[i] = 0.02 + Math.random()/10;  // set step variables
    sy[i] = 0.7 + Math.random();    // set step variables
    document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px;LEFT: 15px;\"><img src='"+image+"' border=\"0\"><\/div>");
}

function animation() {  // animation function
    for (i = 0; i < no; ++ i) {  // iterate for every dot
        py[i] += sy[i];
            if (py[i] > dheight-50) {
                px[i] = Math.random()*(dwidth-am[i]-100);
                py[i] = toppos;
                sx[i] = 0.02 + Math.random()/10;
                sy[i] = 0.7 + Math.random();
            }
            cv[i] += sx[i];
            document.getElementById("dot"+i).style.top=py[i]+"px";
            document.getElementById("dot"+i).style.left=px[i] + am[i]*Math.sin(cv[i])+"px"; 
        }
        atime=setTimeout("animation()", speed);

}

function hideimage(){
    if (window.atime) clearTimeout(atime)
        for (i=0; i<no; i++)
            document.getElementById("dot"+i).style.visibility="hidden"
}
if (ie4up||ns6up){
animation();
if (time>0)
    setTimeout("hideimage()", time*1000)
}
animation();

/*   Free Script provided by HIOXINDIA            */
/*   visit us at http://www.hscripts.com     */
/*   This is a copyright product of hioxindia.com */
</script>
</html>
</apex:page>
Note : Place any image you like in static resource and change image url in this line
var image="{!$Resource.snowfall}";


Debug Logs in Salesforce

A debug log can record database operations, system processes  and errors that occur
when executing a transaction or running unit tests.

Debug logs can contain information about:

1)Database changes
2)HTTP callouts
3)Apex errors
4)Resources used by Apex
5)Workflow rules
6)Assignment rules
7)Approval processes
8)Validation rules

Setting Debug Log :
step 1: Go to setup--> Monitoring -->Debug logs or Logs-->Debug Logs
step 2: click new and then select any user and then click save.

viewing Debug Logs: when you run visualforce pages/classes or any other processes,
debug logs are created and we can view them in debug logs page.


Multiple tabs in visualforce page

visualforce page code:

  <apex:page id="thePage">
    <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
        <apex:tab label="One" name="name1" id="tabOne">content for tab one</apex:tab>
        <apex:tab label="Two" name="name2" id="tabTwo">content for tab two</apex:tab>
    </apex:tabPanel>
</apex:page>
  
Output:

          







If you want to include visualforce pages in tabs ,the following code helps you.
Here Page1 and Page2 are visualforce pages
<apex:page >
    <apex:tabPanel >
        <apex:tab label="First Tab">
            <apex:include pageName="Page1"/>
        </apex:tab>
        <apex:tab label="second Tab">
            <apex:include pageName="Page2"/>
        </apex:tab>
    </apex:tabPanel>
</apex:page>

Batch Apex in Salesforce

Batch Apex in Salesforce

Batch Jobs : What is the need ?

       As you all might know about the salesforce governor limits on its data. When you want to fetch thousands of records or fire DML on thousands of rows on objects it is very complex in salesforce and it does not allow you to operate on more than certain number of records which satisfies the Governor limits.
But for medium to large enterprises, it is essential to manage thousands of records every day. Adding/editing/deleting them when needed.
There is a  powerful concept called Batch Apex. Batch Apex allows you to handle more number of records and manipulate them by using a specific syntax.
The execution logic of the batch class is called once for each batch of records. The default batch size is 200 records. You can also specify a custom batch size.
Batch job are made to perform common UPSERT operation on a scheduled basis. The Batch apex can be used to conveniently perform time to time task and some real complex job ranging from data cleansing, archiving the data to the other quality improvements.
Advantages:
  • A large number of records can be processed. Even batch size is changeable.
  • Result of one batch cannot affect other batch.It means every batch is descrete.
  • Each batch execution is considered a discrete transaction. With each new batch of records, a new set of governor limits is in effect. In this way, it’s easier to ensure that your code stays within the governor execution limits.
  • Another benefit of discrete batch transactions is to allow for partial processing of a batch of records in case one batch fails to process successfully, all other batch transactions aren’t affected and aren’t rolled back if they were processed successfully.
How to Implement:
Develop Apex class implementing 'Batchable' Interface. This interface has three operation defined to it. In order to implement batch processing, first we need to create an Apex class that implements Database.Batchable<sObject> interface.
This interface demands for three methods to be implemented:
Start - Use this to basically collect the records and then pass on to execute method
Execute-  Use this to process the records.
Finish - Called once, when processing get finished and can be used for operations like sending confirmation email
Lets jump to code, for better understanding.
Example:
Global class batchAccountUpdate implements Database.Batchable<sObject> {
   Global Database.QueryLocator start(Database.BatchableContext BC) {
       String query = 'SELECT Id,Name FROM Account';
       return Database.getQueryLocator(query);
   }   
   Global void execute(Database.BatchableContext BC, List<Account> scope) {
        for(Account a : scope) {
a.Name = a.Name + 'Updated';            
        }
        update scope;
   }   
   Global void finish(Database.BatchableContext BC) {
AsyncApexJob a = [SELECT Id, Status, NumberOfErrors,
JobItemsProcessed,TotalJobItems, CreatedBy.Email
FROM AsyncApexJob WHERE Id =:BC.getJobId()];
String UserEmail = 'Any EMAIL';
Messaging.SingleEmailMessage mail = new      Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {UserEmail});
mail.setReplyTo('ANY EMAIL');
mail.setSenderDisplayName('Batch Processing');
mail.setSubject('Batch Process Completed');
mail.setPlainTextBody('Batch Process has completed');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
   }
}

How to run Batch Process:

In order to run batch process, you need to use
Database.executeBatch() method.
Open the developer console and then write a small snippet of apex code as shown below
batchAccountUpdate batchJob = new batchAccountUpdate();
Database.executeBatch(batchJob);
Scheduling Batch Process:
We can also schedule batch apex. In order to schedule batch class,we need to write schedulable batch class.
Example:
Global class batchAccountUpdateSchedular implements Schedule
{
Global void execute(SchedulableContext sc)
{
          batchAccountUpdate b= new batchAccountUpdate();
  Database.executebatch(b);
}
}
Now you can schedule this apex class by using Schedule Apex in Salesforce.

Tuesday, August 26, 2014

List Views in salesforce

List Views in salesforce

Sample code to display list view of account object in visualforce page

<apex:page showHeader="true" tabstyle="Account">
    <apex:ListViews type="Account" />
    <apex:ListViews type="Account" />
</apex:page>


The output will be as shown in the image below.


Date picker in Visualforce page

Date picker in Visualforce page

The following is the sample code to display date picker in visualforce page

<apex:page >
<apex:form >
<table>
<td> Date<br></br><input id="t" name="datee" onfocus="DatePicker.pickDate(false,
't', false);" size="12" tabindex="28" type="text" />
<span class="dateFormat"  style="display:none">[&nbsp;

<a href="javascript&colon;DatePicker.insertDate('', 't', true);"
>2/3/2011</a>&nbsp;]</span></td>
</table>
</apex:form>
</apex:page>

The output will be as shown in the image given below


                   

Thursday, July 31, 2014

How to change background colour of a selected row of a page block table?


<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
    <style>
    .rowColor {
            background-color:orange;
            }
    </style>
    <script>
        var pRow='';
        function highlightElem(a) {             
            var c=a.className;
          //  alert(c);
            a.className="rowColor";
            if(pRow==''){
                pRow=a;
            }
            else {
                if(pRow.innerHTML!=a.innerHTML) {
                    pRow.className=c;
                    pRow=a;
                }
            }
        }
    </script>
        <apex:form >
        <apex:pageBlock >
            <apex:PageBlockTable value="{!accounts}" var="r" onRowClick="highlightElem(this)" >
                <apex:column value="{!r.Name}" />
                <apex:column value="{!r.Phone}" />
                <apex:column value="{!r.Type}" />
            </apex:PageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Friday, July 11, 2014

How Can I Become A MVP (Force.com)


At First I would like to thank Ankit Arora,for sharing very useful information on "How Can I Become A MVP (Force.com) " on his blog.

I am sharing a link to  that so that all of my friends will go through that link and gain some knowledge.

http://forceguru.blogspot.in/2013/04/how-can-i-become-mvp-forcecom.html

Wednesday, July 9, 2014

System.TypeException: Invalid date: 1/1/2014 error issue

System.TypeException: Invalid date: 1/1/2014 error issue

whenever we are assaigning a string which contains date to date field ,we get this error because of different date format.So to resolve this issue we need to change date format.

For example I got this error  "System.TypeException: Invalid date: 1/1/2014"

I resolved this issue in the following way..
string   DateScheduled='1/1/2014';
String[] myDateOnly = DateScheduled.split(' ');
            String[] strDate = myDateOnly[0].split('/');
            Integer myIntDate = integer.valueOf(strDate[1]);
            Integer myIntMonth = integer.valueOf(strDate[0]);
            Integer myIntYear = integer.valueOf(strDate[2]);
            account.DateScheduled__c=Date.newInstance(myIntYear, myIntMonth, myIntDate);

Here DateScheduled__c is a custom date field in account object.
Hope this helps you...

Convert string to date in apex

In order to convert  string value to date,use valueOf().

For Example

String datevalue = '1/2/2014';
Date d = Date.valueOf(datevalue );

Thursday, June 19, 2014

How to set line numbers in eclipse?

In order to set line numbers in eclipse
go to window --> preferences --> click General --> click Editors --> click Text Editors








  


Now in the Text Editors window, make the checkbox of Show line numbers to true.

Then click Apply button and then ok button.

Thats it..

Now you will be able to see line numbers as shown below. 


Thursday, June 12, 2014

How to display image in word document?


step 1 :First upload the image to document.

Procedure: click on documents tab,then click new.Enter the details and upload the image.

Note:Make sure Externally available image checkbox is clicked.
step 2:now create the visualforce page with the following code.

<apex:page contentType="application/msword#Test.doc">
<head>
</head>
<body>
  This is your new Page
<apex:image url="https://c.ap1.content.force.com/servlet/servlet.ImageServer?id=01590000003w0sx&oid=00D90000000j4R8
 &lastMod=1399273218000" width="50" height="50" />
</body>
</apex:page>


note: To get image url,follow the steps

step 1:open the document where you uploaded the image.
step 2:Right click on the image icon and then copy image location.

Replace url of <apex:image> with the above copied image url.


When you run the visualforce page, the ouptut will be as follows.


Wednesday, June 11, 2014

How to get salesforce Webinars and articles ?

At first open the url " https://developer.salesforce.com/content/type/Webinar?language=en " in any browser.

The webpage will look like this.


Here We can find all webinars and articles related to salesforce.

Filters are also present to filter webinars or articles.
For example we can filter webinars or articles based on category and also we can filter based on year.


Enjoy the webinars or articles which you like.

How to get salesforce online training videos?


At first open the url " https://help.salesforce.com/hthome?err=1&siteLang=en_US.In " in
 any browser.

The webpage will look like this.
Now scroll the page down.You can find online training in Training section as highlighted
in the image below.
Go through the videos and Enjoy....


How to display standard list view functionality in visualforce page?

To display listviews ,we have <apex:listviews> component.

syntax: <apex:ListViews type="Account" /> where type indicates The Salesforce object
 for which list views are displayed.

For example to display account listviews in visualforce page,
first create a visualforce page with the following code

<apex:page standardController="Account" >
<form>
<apex:ListViews type="account" />
</form>
</apex:page>

when we run the above visualforce page the output will look like this


Thursday, June 5, 2014

How to do mathematical functions in visualforce page?


Generally we do mathematical operations in apex classes and get that values to visualforce page.

But there may be situations where we need to do mathematical operations in visualforce page itself.For example if we have professional edition,then we cannot create apex classes.
At that time we can do mathematical operations in vf page itself in the following way.

For example to find sum of list of values.first we create <apex:variabe> and
then inside <apex:repeat> tag we perform the mathematical calculations.

The below example will find the sum of a field(quantity) of all opportunitylineitems
associated with opportunity.

<apex:page standardController="opportunity" >
<apex:form >
     
          <apex:repeat value="{!opportunity}" var="qList">
          <apex:variable value="{!0}" var="salesprice"/>
          <apex:variable value="{!0}" var="sumofquantity"/>
             <apex:repeat value="{!qList.opportunitylineitems}" var="QlItem">
                 <apex:variable value="{!salesprice +  if(QlItem.Unitprice!= null,QlItem.Unitprice,0)}" var="salesprice"/>
                 <apex:variable value="{!sumofquantity +  if(QlItem.Quantity!= null,QlItem.Quantity,0)}" var="sumofquantity"/>
                 <apex:outputLabel >Total Quantity</apex:outputLabel><apex:outputLabel value="{!sumofquantity}" title="Total"/>  <br />  
                 <apex:outputLabel >Total Sales Price</apex:outputLabel><apex:outputLabel value="{!salesprice}" title="Total1"/>  <br />  
                 <apex:outputLabel value="MC= {!if(QlItem.Unitprice == 0,0,round(QlItem.Unitprice/QlItem.Quantity,2))}"/>
             </apex:repeat>

    </apex:repeat>
    
</apex:form>
</apex:page>

 When we run the page by giving opportunity id,the output  will be as follows















                                                                                                                                                                                                                        

Wednesday, April 23, 2014

How to increase the width of a column of page block table

When working with <apex:pageblocktable> ,sometimes we need to adjust the width of columns.
In order to do that we need to use  "columnsWidth" attribute of  <apex:pageblocktable> and specify the width of columns in order in terms of percentages
for examples if there are 3 columns,then

<apex:pageBlockTable value="{!account}" var="item" columnsWidth="60%,20%,20%">

If  column have some input fields,then to increase the textfield area, we can use styes.
For example
   <apex:column headerValue="Site Name">    <apex:inputfield value="{!item.Site}" id="amt" style="width: 360px; height: 40px"/></apex:column>

Here site is a input field.

The following Example will give an idea..

Create a visualforce  page with the folowing code

<apex:page standardController="Account" showHeader="false" sidebar="false">
<apex:form >
    <apex:pageBlock title="Increase Columns Width">

        <apex:pageBlockTable value="{!account}" var="item" columnsWidth="80%,20%">

            <apex:column headerValue="Site Name">    <apex:inputfield value="{!item.Site}" id="amt" style="width: 360px; height: 40px"/></apex:column>
             <apex:column value="{!item.name}"/>

        </apex:pageBlockTable>

    </apex:pageBlock>
</apex:form>
</apex:page>

The output will be as follows







    

Thursday, April 17, 2014

Dev 401 Dumps

1. Standard fiscal years can start on the first day of any month of the year ?
A.True
B.False

Ans. A
2. The organization IDs of your sandboxes remain same each time your sandbox is refreshed
A. TRUE
B. FALSE

Ans. B
3. An opportunity can have only one primary partner
A. TRUE
B. FALSE

Ans. a
4. Which of the following is not a correct statement?
A. Tags can be enabled by enabling Tags permission for the Organization
B. Tags can be enabled by enabling Tags permission for the Profiles
C. Tags can be added on the Records
D. Tags can be accessed from the Sidebar component

Ans. b
5. Encrypted fields are editable regardless of whether the user has the “View Encrypted Data” permission.
A. True
B. False

Ans. A

Sunday, January 5, 2014

Display list of accounts group by picklist field value in visualforce page.

Sometimes we may have the requirement of displaying records of any object group by picklist field value.
In order to do this u need to generate 2 lists one is list of records and other is list of picklist field values.Then in visualforce page u can use nested <apex:repeat> and some conditions to display the records group by picklist field value.

The example below will explain it.
Here is the code for Apex Class:

public with sharing class GroupBy{
 
  public List<account> accounts {get;set;}  
  public Account ac {get;set;}
  public String[] states {get;set;}
  id x;
  public GroupBy()
  {
    ac = [ select Name FROM Account 
    WHERE id = :ApexPages.currentPage().getParameters().get('id')];
     x=ac.id;
  }
  public id getQuantity1() {
     
        return x;
    } 
 
  public void load() {
  List<String> lstPickvals=new List<String>();
  Schema.DescribeFieldResult fieldResult = 
account.active__c.getDescribe();
  List<Schema.PicklistEntry> ple =fieldResult.getPicklistValues();
  system.debug('....'+ple );
  for (Schema.PicklistEntry a:ple ){//forall values in picklist list
      lstPickvals.add(a.getValue());//add value to our final list
   }
   system.debug('....'+lstPickvals);
    // for demo purposes limit the states  
    accounts = [Select ID, Name,active__c From account
      Where Active__c IN: lstPickvals];
 
    // dynamically create set of unique states from query
    Set<String> stateSet = new Set<String>();
    for (account a : accounts)
      stateSet.add(a.Active__c);
 
    // convert the set into a string array  
    states = new String[stateSet.size()];
    Integer i = 0;
    for (String state : stateSet) { 
      states[i] = state;
      i++;
    }
 
  }
 
}
The code for visualforce page:

<apex:page controller="GroupBy" action="{!load}" sidebar="false">
 <apex:sectionHeader title="My Sample Display Page" 
subtitle="Group by picklist field value" description=
"shows how you can dynamically group results by field value."/>
 
 <apex:repeat value="{!states}" var="state">
 
 <apex:pageBlock title="{!state}">
 
  <apex:repeat value="{!accounts}" var="account"> 
<apex:outputPanel rendered="{!IF(state=account.Active__c,true,false)}">
    {!account.Name} - {!account.Active__c}<br/>
</apex:outputPanel>
 
   </apex:repeat>
 
    </apex:pageBlock>
 
  </apex:repeat>
 {x}
</apex:page>
 
When we run the visualforce page with accountid,
the output will be as follows