Saturday, 10 March 2012

Rollup Summary using Trigger

//Rollup summary using trigger on conatct
//This is used for  displaying the number of contacts on account

trigger countingcontacsofacc on Contact (after insert,after delete,after update) {
map<id,list<contact>> mapcontactcount=new map<id,list<contact>>();
map<id,Account> accupdate = new map<id,account>();
for(Account acc:[select id,(select id,name from contacts) from account]){
        accupdate .put(,acc);

for(id c:mapcontactcount.keyset()){
update accupdate.values();


Visualforce page for displaying the related contacts based on selected account using map


public class lonchangeaccount{
        public id aid{get;set;}
        public boolean render{get;set;}
        List<selectoption> options=new List<selectoption>();
        public  List<Contact> lstcont{get;set;}
        public lonchangeaccount(){
                    lstcont=new List<contact>();
        Map<id,List<contact>> maplstcont=new Map<id,List<contact>>();
        public List<SelectOption>  getValues(){
                options.add(new selectOption('--None--','--None--'));
                for(Account acc:[select id,name,(select id,name,email from contacts)from account]){
                    options.add(new selectOption(,;
                return options;
        public void  Contactlst(){

<apex:page controller="lonchangeaccount">
<apex:form >
    <apex:pageBlock >
         <apex:actionFunction action="{!Contactlst}" name="change"/>
         <apex:selectList value="{!aid}" multiselect="false" size="1" onchange="change();">
                <apex:selectOptions value="{!values}"/>
          <apex:outputPanel rendered="{!render}" id="balu">
              <apex:pageBlockTable value="{!lstcont}" var="c">
                      <apex:column value="{!}"/>



Joined Reports

Joined Reports Overview
The joined report format lets you view different types of information in a single report. A joined report consists of up to five report blocks, which you add to the report to create multiple views of your data. For each block, you can add regular and summary fields, create custom summary formulas, apply filters, and sort columns. You apply groupings across all blocks in the report, and can add up to three groupings to the blocks, the same as for the summary format.
A joined report can contain data from multiple standard or custom report types. You can add report types to a joined report if they have relationships with the same object or objects. For example, if you have a joined report that contains the Opportunities report type, you can add the Cases report type as well because both have a relationship with the Accounts object.
When a joined report contains multiple report types, some fields are identified as common fields. A field is a common field if it’s shared by all report types or if all report types share a lookup relationship to the field. These fields appear in the Common Fields area in the Fields pane, and can be used to group report blocks.
Each joined report has a principle report type. By default, the principle type is the first one added to the report, and is identified in the Fields pane with a small dot beside its name. For example, if you create the joined report by selecting the Opportunities report type, and then add the Cases type, the Opportunities type is the principle report type.
The principle report type controls how common fields are named. Some common fields have different names or appear in different sections in different report types. In those fields, click  to see the name of the field in other report types.

1)For users to be able to create and edit joined reports, report builder must be enabled for your entire organization. For information on enabling report builder, see Upgrading Report Builder. When report builder isn’t enabled, users can only run joined reports.
2)Joined reports require that the new user interface theme be enabled. Users without the new theme are unable to create, edit, or run joined reports. See Enable New User Interface Theme.
3)Internet Explorer 6 is not supported for joined reports.

Joined reports let you report on information in a single report that, previously, would have required several separate reports. Use joined reports to create a report comparing the number of support cases that are new, closed, or in-progress by priority. This report contains a single standard report type: Cases. First, create the report, add three blocks to the report, filter each block by the appropriate status, and then use the Priority field for grouping.
Use a joined report with multiple report types to create a report containing each of your organization’s deals, and the sales team members and products associated with each deal. First, create a report that includes opportunities and sales team members. Then, add an additional report that includes opportunities and products. Group by opportunity name, and then create two blocks: one contains sales team members and roles, and the other contains the products for each opportunity.

Working with Joined Reports
To get started with joined reports, create a new or edit an existing report in report builder, click the Format drop-down, and choose Joined.
Most of the things you can do with summary or matrix reports you can also do with joined reports. For example, you can find, add, and remove fields; summarize fields; add custom summary fields; and run and save reports. See Working with Report Builder.
Additionally, when working with a joined report, you can:
Add up to 16 report types to the report.
Add additional blocks to the report. A report can have up to 5 blocks.
Add custom summary formulas to each block. You can add up to 10 to each block, and up to 50 for each joined report.
Filter individual blocks using standard and boolean filters.
Sort columns for each block, and hide or show details across blocks.
Change the principle report type.
Click Run Report to run the report. Note that the report is run in the joined report version of the run report page.

 Watch a Demo on Building Joined Reports (3:19 minutes)
Currently, you can’t do the following with joined reports:
1)Create a chart.
2)Add bucketed fields.
3)Add cross filters.
4)Drag and drop filters from the Fields pane on to the Filter pane.
5)Apply conditional highlighting.
6)Schedule or export joined reports.
7)Change the hierarchy for opportunity or activity reports.
8)Use a joined report as the data source for a dashboard.
9)Create analytics snapshots based on joined reports.

Getting Reference FieldsI(Lookup or Master detail) through dynamic apex

Hi , We  had a scenario If  we get a parameter "id" in the  url  then we should  be  able to find out    object reference is ...