• munna123
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 29
    Replies
Hi All,

 I have a custom field "Email_Body__c" on Account. I need to add it to Task&Event and create a report for Task&Events.
 When i try to create a new report for task and events, i should find that field under Task and events, in order to select and include in report.
Hi all... i want to know about the possible ways in which we can integrate sap with salesforce
Hi all.... I want to know about different types of integrations available to integrate sap with sfdc. And even about the different types of web services...
Hi all...

       my requirement is when we delete a record in parent object, a new record with the deleted parent record values should be created in child object.
hi all...here we need to write a trigger. we need to create a contact on contact object for a particular account. when we give the value in phone field of contact, the phone field of parent account of this contact should get updated with the phone field value given in contact object.
am a beginner so not understanding.
here is my coding

trigger tgr_fieldupdate on Contact (after update) {
   list<contact> ls= [select id,phone from contact];
    contact con= trigger.new[0];
    account acc = new account();
        for(contact c:ls){
            c.phone= acc.phone;
            update acc;
        }
    
hii all...

     actually i created a dropdown list for some objects. when we select an object, its fields will be generated with checkins. but am not able to get the records with checkin fields. i created a "view report"button to get records. but how to get them by clicking the "view report" button 
here is my code..

vf page:

<apex:page controller="selectlist">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title="select the required objects below" columns="1" collapsible="false">
<apex:pageBlockSectionItem >
    
          <apex:outputlabel value="Object :" /> 
              <apex:actionRegion >      
            <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise__c" itemLabel="merchandise__c" />
            <apex:selectOption itemValue="invoice__c" itemLabel="invoice__c" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="report" itemLabel="report" />    
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
              </apex:selectList> 
                  <apex:actionSupport event="onchange" rerender="Fieldnames"/>
                <apex:commandbutton value="add"/>
                   </apex:actionRegion>
              </apex:pageBlockSectionItem>
             </apex:pageBlockSection> 
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:pageBlockSection title="these are the fields of selected sobject....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/> 
                  <apex:outputPanel id="Fieldnames">
                        <apex:actionRegion > 
                            <fieldset>
         <apex:panelGrid columns="1" >
             <apex:selectCheckboxes value="{!selectedField}" layout="linedrection-vertical">
              <apex:selectOptions value="{!ObjectFields}" />  
    </apex:selectCheckboxes>
       <apex:commandbutton value="view report" />
           </apex:panelGrid>
              </fieldset>
                        </apex:actionRegion>      
                     </apex:outputPanel>
</apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

controller:

global with sharing class selectlist
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    public account sel{set;get;}
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
             Map<String, Schema.sObjectField> fieldMap = new Map<String, Schema.sObjectField>();
            if(ObjectSchema!=null){

    
             fieldMap = ObjectSchema.getDescribe().fields.getMap();
            }
            List<SelectOption> fieldNames = new List<SelectOption>();
            
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }
}
hii all...

     actually i created a dropdown list for some objects. when we select an object, its fields will be generated with checkins. but am not able to get the records with checkin fields. i created a "view report"button to get records. but how to get them by clicking the "view report" button 
here is my code..

vf page:

<apex:page controller="selectlist">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title="select the required objects below" columns="1" collapsible="false">
<apex:pageBlockSectionItem >
    
          <apex:outputlabel value="Object :" /> 
              <apex:actionRegion >      
            <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise__c" itemLabel="merchandise__c" />
            <apex:selectOption itemValue="invoice__c" itemLabel="invoice__c" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="report" itemLabel="report" />    
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
              </apex:selectList> 
                  <apex:actionSupport event="onchange" rerender="Fieldnames"/>
                <apex:commandbutton value="add"/>
                   </apex:actionRegion>
              </apex:pageBlockSectionItem>
             </apex:pageBlockSection> 
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:pageBlockSection title="these are the fields of selected sobject....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/> 
                  <apex:outputPanel id="Fieldnames">
                        <apex:actionRegion > 
                            <fieldset>
         <apex:panelGrid columns="1" >
             <apex:selectCheckboxes value="{!selectedField}" layout="linedrection-vertical">
              <apex:selectOptions value="{!ObjectFields}" />  
    </apex:selectCheckboxes>
       <apex:commandbutton value="view report" />
           </apex:panelGrid>
              </fieldset>
                        </apex:actionRegion>      
                     </apex:outputPanel>
</apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

controller:

global with sharing class selectlist
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    public account sel{set;get;}
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
             Map<String, Schema.sObjectField> fieldMap = new Map<String, Schema.sObjectField>();
            if(ObjectSchema!=null){

    
             fieldMap = ObjectSchema.getDescribe().fields.getMap();
            }
            List<SelectOption> fieldNames = new List<SelectOption>();
            
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }
}
here in the below code am getting the list of all objects in an organisation. but i need only to select only few objects like account, contact, solutions etc.. how to get this.

<apex:page controller="dynamic1" >
    <apex:form id="op">
        <apex:pageBlock >
            <apex:pageBlockSection id="od1" columns="1">
                <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Object List"></apex:outputLabel>
                    <apex:selectList size="1" value="{!selectedobj}">
                        <apex:selectOptions value="{!objects}" ></apex:selectOptions>
                        <apex:actionSupport action="{!details}" event="onchange" rerender="op"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <br/>
                <br/>
                <br/>         
                <apex:pageBlockSection >
               <apex:pageBlockSectionItem >
           <apex:outputLabel value="fields List:"></apex:outputLabel>

                    <apex:panelGrid columns="3" id="od" >
                        <apex:panelGroup style="width:40%" >
                            <apex:selectList size="6" value="{!sfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fnoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                        <apex:panelGroup style="width:20%;hieght:120px;">
                            <table hieght="120px">
                                <tr><td><apex:commandButton value="Add" action="{!addfields}" style="width:80px;" reRender="od"  /> </td></tr>
                                <tr><td><apex:commandButton value="Remove" action="{!removefields}" style="width:80px;" reRender="od1"  /> </td></tr>
                            </table>
                        </apex:panelGroup>
                        <apex:panelGroup >
                            <apex:selectList size="6"  value="{!rfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fsoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                    </apex:panelGrid>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <apex:pageBlockSectionItem >
                    <apex:pageBlockTable value="{!mydata}" var="a" >
                        <apex:repeat value="{!myfields}" var="b">
                            <apex:column value="{!a[b]}"/>
                        </apex:repeat>
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <br/>
            <br/>
            <br/>
            <apex:commandButton value="click" action="{!querymydata}" reRender="op"/>{!query}
        </apex:pageBlock>    
    </apex:form>
</apex:page>

controller:
-----------------
 public class dynamic1 {
    
    public list<selectoption>objects{set;get;}
    public list<selectoption>fsoption{set;get;}
    public list<selectoption>fnoption{set;get;}
    public list<string> sfields{set;get;}
    public list<string> rfields{set;get;}
    public list<string>objlst{set;get;}
    public list<string>fields{set;get;}
    public set<string>fselected{set;get;}
    public set<string>fnotselected{set;get;}
    public map<string,schema.SObjectField> mfields;
    public map<string,schema.SObjectType> mobjects{set;get;}
    public string selectedobj{set;get;}
    public string objdiscription{set;get;}
    public string query{set;get;}
    public list<string>myfields{set;get;} 
    public list<sobject>mydata{set;get;}
    public dynamic1(){
        myfields=new list<string>();
        mydata=new list<sobject>();
        objects=new list<selectoption>();
        objlst=new list<string>();
        sfields=new list<string>();
        rfields=new list<string>();
        fields=new list<string>();
        fselected=new set<string>();
        fnotselected=new set<string>();
        fsoption=new list<selectoption>();
        fnoption=new list<selectoption>();
        mobjects=schema.getGlobalDescribe();
        objlst.addall(mobjects.keyset());
            objlst.sort();
        selectoption p=new selectoption('none','-none-');
        objects.add(p);
        for(string s:objlst){
            selectoption op=new selectoption(s,s);
            objects.add(op);
        }
        
    }
    
    public void details(){
        schema.DescribeSObjectResult mobj=mobjects.get(selectedobj).getDescribe();
        mfields=mobjects.get(selectedobj).getDescribe().fields.getMap();
        fields.addAll(mfields.keySet());
        fnotselected.addAll(fields);
        show();
    }
    public void show(){
 fnoption.clear();
        fsoption.clear();
        for(string s:fnotselected){
            selectoption op=new selectoption(s,s);
            fnoption.add(op);
        }
        for(string s1:fselected){
            selectoption op1=new selectoption(s1,s1);
            fsoption.add(op1);
            
        }
        
    }
    public void addfields(){
        fnotselected.removeAll(sfields);
        fselected.addAll(sfields);
        show();
    }
    public void removefields(){
        fnotselected.addAll(rfields);
        fselected.removeAll(rfields);
        show();
    }
    public void querymydata(){
         query ='select id';
        myfields.addAll(fselected);
        for(string s:fselected){
            query=query+','+s;
        }
        query=query + ' from ' + selectedobj;
        mydata=database.query(query);
    }
}
here in the below code am getting the list of all objects in an organisation. but i need only to select only few objects like account, contact, solutions etc.. how to get this.

<apex:page controller="dynamic1" >
    <apex:form id="op">
        <apex:pageBlock >
            <apex:pageBlockSection id="od1" columns="1">
                <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Object List"></apex:outputLabel>
                    <apex:selectList size="1" value="{!selectedobj}">
                        <apex:selectOptions value="{!objects}" ></apex:selectOptions>
                        <apex:actionSupport action="{!details}" event="onchange" rerender="op"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <br/>
                <br/>
                <br/>         
                <apex:pageBlockSection >
               <apex:pageBlockSectionItem >
           <apex:outputLabel value="fields List:"></apex:outputLabel>

                    <apex:panelGrid columns="3" id="od" >
                        <apex:panelGroup style="width:40%" >
                            <apex:selectList size="6" value="{!sfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fnoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                        <apex:panelGroup style="width:20%;hieght:120px;">
                            <table hieght="120px">
                                <tr><td><apex:commandButton value="Add" action="{!addfields}" style="width:80px;" reRender="od"  /> </td></tr>
                                <tr><td><apex:commandButton value="Remove" action="{!removefields}" style="width:80px;" reRender="od1"  /> </td></tr>
                            </table>
                        </apex:panelGroup>
                        <apex:panelGroup >
                            <apex:selectList size="6"  value="{!rfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fsoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                    </apex:panelGrid>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <apex:pageBlockSectionItem >
                    <apex:pageBlockTable value="{!mydata}" var="a" >
                        <apex:repeat value="{!myfields}" var="b">
                            <apex:column value="{!a[b]}"/>
                        </apex:repeat>
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <br/>
            <br/>
            <br/>
            <apex:commandButton value="click" action="{!querymydata}" reRender="op"/>{!query}
        </apex:pageBlock>    
    </apex:form>
</apex:page>

controller:
-----------------
 public class dynamic1 {
    
    public list<selectoption>objects{set;get;}
    public list<selectoption>fsoption{set;get;}
    public list<selectoption>fnoption{set;get;}
    public list<string> sfields{set;get;}
    public list<string> rfields{set;get;}
    public list<string>objlst{set;get;}
    public list<string>fields{set;get;}
    public set<string>fselected{set;get;}
    public set<string>fnotselected{set;get;}
    public map<string,schema.SObjectField> mfields;
    public map<string,schema.SObjectType> mobjects{set;get;}
    public string selectedobj{set;get;}
    public string objdiscription{set;get;}
    public string query{set;get;}
    public list<string>myfields{set;get;} 
    public list<sobject>mydata{set;get;}
    public dynamic1(){
        myfields=new list<string>();
        mydata=new list<sobject>();
        objects=new list<selectoption>();
        objlst=new list<string>();
        sfields=new list<string>();
        rfields=new list<string>();
        fields=new list<string>();
        fselected=new set<string>();
        fnotselected=new set<string>();
        fsoption=new list<selectoption>();
        fnoption=new list<selectoption>();
        mobjects=schema.getGlobalDescribe();
        objlst.addall(mobjects.keyset());
            objlst.sort();
        selectoption p=new selectoption('none','-none-');
        objects.add(p);
        for(string s:objlst){
            selectoption op=new selectoption(s,s);
            objects.add(op);
        }
        
    }
    
    public void details(){
        schema.DescribeSObjectResult mobj=mobjects.get(selectedobj).getDescribe();
        mfields=mobjects.get(selectedobj).getDescribe().fields.getMap();
        fields.addAll(mfields.keySet());
        fnotselected.addAll(fields);
        show();
    }
    public void show(){
 fnoption.clear();
        fsoption.clear();
        for(string s:fnotselected){
            selectoption op=new selectoption(s,s);
            fnoption.add(op);
        }
        for(string s1:fselected){
            selectoption op1=new selectoption(s1,s1);
            fsoption.add(op1);
            
        }
        
    }
    public void addfields(){
        fnotselected.removeAll(sfields);
        fselected.addAll(sfields);
        show();
    }
    public void removefields(){
        fnotselected.addAll(rfields);
        fselected.removeAll(rfields);
        show();
    }
    public void querymydata(){
         query ='select id';
        myfields.addAll(fselected);
        for(string s:fselected){
            query=query+','+s;
        }
        query=query + ' from ' + selectedobj;
        mydata=database.query(query);
    }
}
here is my code.... here am getting all objects. but i need only the selected ones.how can i get only the selected objects and also should get notes and attachments for the records of a selected object...

vf page:

<apex:page controller="dynamic1" >
    <apex:form id="op">
        <apex:pageBlock >
            <apex:pageBlockSection id="od1" columns="1">
                <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Object List"></apex:outputLabel>
                    <apex:selectList size="1" value="{!selectedobj}">
                        <apex:selectOptions value="{!objects}" ></apex:selectOptions>
                        <apex:actionSupport action="{!details}" event="onchange" rerender="op"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <br/>
                <br/>
                <br/>         
                <apex:pageBlockSection >
               <apex:pageBlockSectionItem >
           <apex:outputLabel value="fields List:"></apex:outputLabel>

                    <apex:panelGrid columns="3" id="od" >
                        <apex:panelGroup style="width:40%" >
                            <apex:selectList size="6" value="{!sfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fnoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                        <apex:panelGroup style="width:20%;hieght:120px;">
                            <table hieght="120px">
                                <tr><td><apex:commandButton value="Add" action="{!addfields}" style="width:80px;" reRender="od"  /> </td></tr>
                                <tr><td><apex:commandButton value="Remove" action="{!removefields}" style="width:80px;" reRender="od1"  /> </td></tr>
                            </table>
                        </apex:panelGroup>
                        <apex:panelGroup >
                            <apex:selectList size="6"  value="{!rfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fsoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                    </apex:panelGrid>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <apex:pageBlockSectionItem >
                    <apex:pageBlockTable value="{!mydata}" var="a" >
                        <apex:repeat value="{!myfields}" var="b">
                            <apex:column value="{!a[b]}"/>
                        </apex:repeat>
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <br/>
            <br/>
            <br/>
            <apex:commandButton value="click" action="{!querymydeta}" reRender="op"/>{!query}
        </apex:pageBlock>    
    </apex:form>
</apex:page>

controller:

<apex:page controller="dynamic1" >
    <apex:form id="op">
        <apex:pageBlock >
            <apex:pageBlockSection id="od1" columns="1">
                <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Object List"></apex:outputLabel>
                    <apex:selectList size="1" value="{!selectedobj}">
                        <apex:selectOptions value="{!objects}" ></apex:selectOptions>
                        <apex:actionSupport action="{!details}" event="onchange" rerender="op"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <br/>
                <br/>
                <br/>         
                <apex:pageBlockSection >
               <apex:pageBlockSectionItem >
           <apex:outputLabel value="fields List:"></apex:outputLabel>

                    <apex:panelGrid columns="3" id="od" >
                        <apex:panelGroup style="width:40%" >
                            <apex:selectList size="6" value="{!sfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fnoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                        <apex:panelGroup style="width:20%;hieght:120px;">
                            <table hieght="120px">
                                <tr><td><apex:commandButton value="Add" action="{!addfields}" style="width:80px;" reRender="od"  /> </td></tr>
                                <tr><td><apex:commandButton value="Remove" action="{!removefields}" style="width:80px;" reRender="od1"  /> </td></tr>
                            </table>
                        </apex:panelGroup>
                        <apex:panelGroup >
                            <apex:selectList size="6"  value="{!rfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fsoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                    </apex:panelGrid>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <apex:pageBlockSectionItem >
                    <apex:pageBlockTable value="{!mydata}" var="a" >
                        <apex:repeat value="{!myfields}" var="b">
                            <apex:column value="{!a[b]}"/>
                        </apex:repeat>
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <br/>
            <br/>
            <br/>
            <apex:commandButton value="click" action="{!querymydeta}" reRender="op"/>{!query}
        </apex:pageBlock>    
    </apex:form>
</apex:page>
i need to get only the first 4 fields for any object selected from a dropdown, and the records with the selected fields and respective notes and attachments should get displayed....
hiii all,
           
when i select the required object fom dropdown and click "add" button, i have to get the list of fields of that particular object with checkboxes. when i checkin some fields like phone, name and all then i need to get all the records of that object with the selected field values. i have a program regarding this.  and i want to improve my program so that if i checkin and click " view report" button, i have to get the records of that particular object with selected fields and the list of notes and attachments (if present) for all records of that selected object...


<apex:page controller="objectController">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title= "select the objects below">
<apex:pageBlockSectionItem >
                  <apex:outputlabel value = "Object Names :" /> 
                      <apex:actionRegion >      
                           <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise" itemLabel="merchandise" />
            <apex:selectOption itemValue="invoice" itemLabel="invoice" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
            <apex:actionSupport event="onchange" rerender="myFields"/>
                            </apex:selectList>
                          <apex:commandbutton value="add"/>
                     </apex:actionRegion>                         
              </apex:pageBlockSectionItem>
               </apex:pageBlockSection>
          
<apex:pageBlockSection title ="these are the fields....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/>   
                      <apex:outputPanel id="myFields">   
                        <apex:actionRegion >  
                           <apex:selectCheckboxes value="{!selectedField}">
    <apex:selectOptions value="{!ObjectFields}" />
    </apex:selectCheckboxes>
      <apex:commandbutton value="view report"/>     
                        </apex:actionRegion>      
                     </apex:outputPanel>
              </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
             
      </apex:pageBlock>
  </apex:form>
</apex:page>

apex:
------------
public class objectController
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            Map<String, Schema.sObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
            List<SelectOption> fieldNames = new List<SelectOption>();
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }       
}   
hiiii,
            my requirement is when i select the required object fom dropdown and click "add" button, i have to get the list of fields of that particular object with checkboxes. when i checkin some fields like phone, name and all then i need to get all the records of that object with the selected field values. i want to improve my program so that if i checkin and click " view report" button, i have to get the records of that particular object with selected fields and the list of notes and attachments (if present) for all records of that selected object...
              i got upto the field types. after selecting checkins of the required field types, am not able to get the records with the filed value of the particular object. and even i need to get the notes and attachments list of that particular record in another pageblock section..

here is the program

<apex:page controller="objectController">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title="select the objects below">
<apex:pageBlockSectionItem >
          <apex:outputlabel value="Object Names :" /> 
              <apex:actionRegion >      
            <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise__c" itemLabel="merchandise__c" />
            <apex:selectOption itemValue="invoice__c" itemLabel="invoice__c" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="report" itemLabel="report" />    
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>

            <apex:actionSupport event="onchange" rerender="myFields"/>
                            </apex:selectList>
                   <form action ="action_page.php">
                   </form>
                  <apex:commandbutton value="add"/>
                  <form action ="action_page.php">
                      
                  </form>
                        </apex:actionRegion>
        
              </apex:pageBlockSectionItem>
             </apex:pageBlockSection> 
    </apex:pageBlock>
    
    <apex:pageBlock >
        <apex:pageBlockSection title="these are the fields....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/>   
                      <apex:outputPanel id="myFields">   
                        <apex:actionRegion >  
        <apex:selectCheckboxes value="{!selectedField}">
    <apex:selectOptions value="{!ObjectFields}" />
    </apex:selectCheckboxes>
     <apex:actionSupport event="onchange" rerender="myFieldsLabel"/>
       <apex:commandbutton value="view report"/>     
                        </apex:actionRegion>      
                     </apex:outputPanel>
              </apex:pageBlockSectionItem>

          </apex:pageBlockSection>
       </apex:pageBlock>
    
  </apex:form>
</apex:page>
*****************************
public class objectController
{
    public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();

    public String selectedObject {get; set;}

    public String selectedField {get; set;}

    Public objectController()
    {   
        selectedObject = 'account';
    }

    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }

     public List<SelectOption> getObjectFields() 
     {
            Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            Map<String, Schema.SObjectField> fieldMap =
                ObjectSchema.getDescribe().fields.getMap();
            List<SelectOption> fieldNames = new List<SelectOption>();
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
              fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
            }
            return fieldNames;
      }       
 }
hiii,
           my requirement is when i select the required object fom dropdown and click "add" button, i have to get the list of fields of that particular object with checkboxes. when i checkin some fields like phone, name and all then i need to get all the records of that object with the selected field values. i have a program regarding this. but the thing is its not working for custom objects. it is giving some error... and i want to improve my program so that if i checkin and click " view report" button, i have to get the records of that particular object with selected fields and the list of notes and attachments (if present) for all records of that selected object...
 
here is my code

vf page:
-----------
<apex:page controller="objectController">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title= "select the objects below">
<apex:pageBlockSectionItem >
                  <apex:outputlabel value = "Object Names :" /> 
                      <apex:actionRegion >      
                           <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise" itemLabel="merchandise" />
            <apex:selectOption itemValue="invoice" itemLabel="invoice" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
            <apex:actionSupport event="onchange" rerender="myFields"/>
                            </apex:selectList>
                          <apex:commandbutton value="add"/>
                     </apex:actionRegion>                         
              </apex:pageBlockSectionItem>
               </apex:pageBlockSection>
          
<apex:pageBlockSection title ="these are the fields....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/>   
                      <apex:outputPanel id="myFields">   
                        <apex:actionRegion >  
                           <apex:selectCheckboxes value="{!selectedField}">
    <apex:selectOptions value="{!ObjectFields}" />
    </apex:selectCheckboxes>
      <apex:commandbutton value="view report"/>     
                        </apex:actionRegion>      
                     </apex:outputPanel>
              </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
             
      </apex:pageBlock>
  </apex:form>
</apex:page>

apex:
------------
public class objectController
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            Map<String, Schema.sObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
            List<SelectOption> fieldNames = new List<SelectOption>();
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }       
}  

 my requirement is when i select the required object fom dropdown and click "add" button, i have to get the list of fields of that particular object with checkboxes. when i checkin some fields like phone, name and all then i need to get all the records of that object with the selected field values. i have a program regarding this. but the thing is its not working for custom objects. it is giving some error... and i want to improve my program so that if i checkin and click " view report" button, i have to get the records of that particular object with selected fields and the list of notes and attachments (if present) for all records of that selected object...
 
here is my code

vf page:
-----------
<apex:page controller="objectController">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title= "select the objects below">
<apex:pageBlockSectionItem >
                  <apex:outputlabel value = "Object Names :" /> 
                      <apex:actionRegion >      
                           <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise" itemLabel="merchandise" />
            <apex:selectOption itemValue="invoice" itemLabel="invoice" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
            <apex:actionSupport event="onchange" rerender="myFields"/>
                            </apex:selectList>
                          <apex:commandbutton value="add"/>
                     </apex:actionRegion>                         
              </apex:pageBlockSectionItem>
               </apex:pageBlockSection>
          
<apex:pageBlockSection title ="these are the fields....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/>   
                      <apex:outputPanel id="myFields">   
                        <apex:actionRegion >  
                           <apex:selectCheckboxes value="{!selectedField}">
    <apex:selectOptions value="{!ObjectFields}" />
    </apex:selectCheckboxes>
      <apex:commandbutton value="view report"/>     
                        </apex:actionRegion>      
                     </apex:outputPanel>
              </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
             
      </apex:pageBlock>
  </apex:form>
</apex:page>

apex:
------------
public class objectController
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            Map<String, Schema.sObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
            List<SelectOption> fieldNames = new List<SelectOption>();
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }       
}          
i got a code in which we get a dropdown of all objects available and also the drop down of the fields.. when we select an object from dropdown, it automatically generates list of fields of that particular object in dropdown.  but i need to create a page so that when we select an object from drop down, and we click a button like "add", the list of fields of that particular object should get displayed with checkboxes.. if we checkin some fields, the values of that fields should be displayed..

the code am having is...

can any one help to get out of this




<apex:page controller="objectController">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection columns="2">

              <apex:pageBlockSectionItem >
                  <apex:outputlabel value="Object Names :"/> 
                      <apex:actionRegion >      
                           <apex:selectList value="{!selectedObject}" size="1">
                                    <apex:selectOptions value="{!ObjectNames}"/>
                                    <apex:actionSupport event="onchange" rerender="myFields"/>
                            </apex:selectList>
                     </apex:actionRegion>                         
              </apex:pageBlockSectionItem>

              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/>   
                      <apex:outputPanel id="myFields">   
                        <apex:actionRegion >  
                           <apex:selectList value="{!selectedField}" size="1">
                                <apex:selectOptions value="{!ObjectFields}"/>
                            </apex:selectList>
                        </apex:actionRegion>      
                     </apex:outputPanel>
              </apex:pageBlockSectionItem>

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

*************************************************************************


public class objectController
{
    public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();

    public String selectedObject {get; set;}

    public String selectedField {get; set;}

    Public objectController()
    {   
        selectedObject = 'account';
    }

    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }

     public List<SelectOption> getObjectFields() 
     {
            Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            Map<String, Schema.SObjectField> fieldMap =
                ObjectSchema.getDescribe().fields.getMap();
            List<SelectOption> fieldNames = new List<SelectOption>();
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
              //fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
            }
            return fieldNames;
      }       
}
i have a vf page which gives the list of fields when we select an object from dropdown. but i need to create a page so that when we select an object from drop down, and we click a button like "add", the list of fields of that particular object should get displayed with checkboxes.. if we checkin some fields, the values of that fields should be displayed 
actually i created a custom field "contacts name" in account object. under a particular account if we create contacts they should get displayed in that custom field seperated by ",". similarly if we delete a contact, remaining group of contacts should be displayed under that particular account... i did as below but its not working..... can u correct it plz

trigger tgr_updating_contact_2 on Contact (after insert, after update, after delete) {
  set<id>accid = new set<id>();
    if(trigger.isdelete){
    for(contact c:trigger.old){
        accid.add(c.accountid);
    }
   }
    else{
        for(contact c:trigger.new){
        accid.add(c.accountid);
    }
   }
        list<account>accnt = new list<account>();
        accnt = [select id, contacts_name__c,(select firstname, lastname from contacts) from account where id in:accid];
        for(account a:accnt){
            a.contacts_name__c = null;
        for(contact c:a.contacts){
                if(a.contacts_name__c==null)
                    a.contacts_name__c = c.lastname;
                else
                    a.contacts_name__c = c.lastname+ ','+ a.contacts_name__c;
    }
        for(contact c:a.contacts){
                if(Trigger.isDelete && c.AccountId != null){
              a.contacts_name__c= a.contacts_name__c;
         }
       }
     }
        update accnt;
}
using triggers how to get the list of remaining contacts seperated by "," in custom field created in accountobject related to contact obj 
 
Hi All,

 I have a custom field "Email_Body__c" on Account. I need to add it to Task&Event and create a report for Task&Events.
 When i try to create a new report for task and events, i should find that field under Task and events, in order to select and include in report.
Hi all...

       my requirement is when we delete a record in parent object, a new record with the deleted parent record values should be created in child object.
hi all...here we need to write a trigger. we need to create a contact on contact object for a particular account. when we give the value in phone field of contact, the phone field of parent account of this contact should get updated with the phone field value given in contact object.
am a beginner so not understanding.
here is my coding

trigger tgr_fieldupdate on Contact (after update) {
   list<contact> ls= [select id,phone from contact];
    contact con= trigger.new[0];
    account acc = new account();
        for(contact c:ls){
            c.phone= acc.phone;
            update acc;
        }
    
hii all...

     actually i created a dropdown list for some objects. when we select an object, its fields will be generated with checkins. but am not able to get the records with checkin fields. i created a "view report"button to get records. but how to get them by clicking the "view report" button 
here is my code..

vf page:

<apex:page controller="selectlist">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title="select the required objects below" columns="1" collapsible="false">
<apex:pageBlockSectionItem >
    
          <apex:outputlabel value="Object :" /> 
              <apex:actionRegion >      
            <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise__c" itemLabel="merchandise__c" />
            <apex:selectOption itemValue="invoice__c" itemLabel="invoice__c" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="report" itemLabel="report" />    
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
              </apex:selectList> 
                  <apex:actionSupport event="onchange" rerender="Fieldnames"/>
                <apex:commandbutton value="add"/>
                   </apex:actionRegion>
              </apex:pageBlockSectionItem>
             </apex:pageBlockSection> 
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:pageBlockSection title="these are the fields of selected sobject....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/> 
                  <apex:outputPanel id="Fieldnames">
                        <apex:actionRegion > 
                            <fieldset>
         <apex:panelGrid columns="1" >
             <apex:selectCheckboxes value="{!selectedField}" layout="linedrection-vertical">
              <apex:selectOptions value="{!ObjectFields}" />  
    </apex:selectCheckboxes>
       <apex:commandbutton value="view report" />
           </apex:panelGrid>
              </fieldset>
                        </apex:actionRegion>      
                     </apex:outputPanel>
</apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

controller:

global with sharing class selectlist
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    public account sel{set;get;}
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
             Map<String, Schema.sObjectField> fieldMap = new Map<String, Schema.sObjectField>();
            if(ObjectSchema!=null){

    
             fieldMap = ObjectSchema.getDescribe().fields.getMap();
            }
            List<SelectOption> fieldNames = new List<SelectOption>();
            
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }
}
here in the below code am getting the list of all objects in an organisation. but i need only to select only few objects like account, contact, solutions etc.. how to get this.

<apex:page controller="dynamic1" >
    <apex:form id="op">
        <apex:pageBlock >
            <apex:pageBlockSection id="od1" columns="1">
                <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Object List"></apex:outputLabel>
                    <apex:selectList size="1" value="{!selectedobj}">
                        <apex:selectOptions value="{!objects}" ></apex:selectOptions>
                        <apex:actionSupport action="{!details}" event="onchange" rerender="op"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <br/>
                <br/>
                <br/>         
                <apex:pageBlockSection >
               <apex:pageBlockSectionItem >
           <apex:outputLabel value="fields List:"></apex:outputLabel>

                    <apex:panelGrid columns="3" id="od" >
                        <apex:panelGroup style="width:40%" >
                            <apex:selectList size="6" value="{!sfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fnoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                        <apex:panelGroup style="width:20%;hieght:120px;">
                            <table hieght="120px">
                                <tr><td><apex:commandButton value="Add" action="{!addfields}" style="width:80px;" reRender="od"  /> </td></tr>
                                <tr><td><apex:commandButton value="Remove" action="{!removefields}" style="width:80px;" reRender="od1"  /> </td></tr>
                            </table>
                        </apex:panelGroup>
                        <apex:panelGroup >
                            <apex:selectList size="6"  value="{!rfields}" multiselect="true" style="width:200px;hieght:150px;">
                                <apex:selectOptions value="{!fsoption}"></apex:selectOptions>
                            </apex:selectList>
                        </apex:panelGroup>
                    </apex:panelGrid>
                </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                <apex:pageBlockSectionItem >
                    <apex:pageBlockTable value="{!mydata}" var="a" >
                        <apex:repeat value="{!myfields}" var="b">
                            <apex:column value="{!a[b]}"/>
                        </apex:repeat>
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <br/>
            <br/>
            <br/>
            <apex:commandButton value="click" action="{!querymydata}" reRender="op"/>{!query}
        </apex:pageBlock>    
    </apex:form>
</apex:page>

controller:
-----------------
 public class dynamic1 {
    
    public list<selectoption>objects{set;get;}
    public list<selectoption>fsoption{set;get;}
    public list<selectoption>fnoption{set;get;}
    public list<string> sfields{set;get;}
    public list<string> rfields{set;get;}
    public list<string>objlst{set;get;}
    public list<string>fields{set;get;}
    public set<string>fselected{set;get;}
    public set<string>fnotselected{set;get;}
    public map<string,schema.SObjectField> mfields;
    public map<string,schema.SObjectType> mobjects{set;get;}
    public string selectedobj{set;get;}
    public string objdiscription{set;get;}
    public string query{set;get;}
    public list<string>myfields{set;get;} 
    public list<sobject>mydata{set;get;}
    public dynamic1(){
        myfields=new list<string>();
        mydata=new list<sobject>();
        objects=new list<selectoption>();
        objlst=new list<string>();
        sfields=new list<string>();
        rfields=new list<string>();
        fields=new list<string>();
        fselected=new set<string>();
        fnotselected=new set<string>();
        fsoption=new list<selectoption>();
        fnoption=new list<selectoption>();
        mobjects=schema.getGlobalDescribe();
        objlst.addall(mobjects.keyset());
            objlst.sort();
        selectoption p=new selectoption('none','-none-');
        objects.add(p);
        for(string s:objlst){
            selectoption op=new selectoption(s,s);
            objects.add(op);
        }
        
    }
    
    public void details(){
        schema.DescribeSObjectResult mobj=mobjects.get(selectedobj).getDescribe();
        mfields=mobjects.get(selectedobj).getDescribe().fields.getMap();
        fields.addAll(mfields.keySet());
        fnotselected.addAll(fields);
        show();
    }
    public void show(){
 fnoption.clear();
        fsoption.clear();
        for(string s:fnotselected){
            selectoption op=new selectoption(s,s);
            fnoption.add(op);
        }
        for(string s1:fselected){
            selectoption op1=new selectoption(s1,s1);
            fsoption.add(op1);
            
        }
        
    }
    public void addfields(){
        fnotselected.removeAll(sfields);
        fselected.addAll(sfields);
        show();
    }
    public void removefields(){
        fnotselected.addAll(rfields);
        fselected.removeAll(rfields);
        show();
    }
    public void querymydata(){
         query ='select id';
        myfields.addAll(fselected);
        for(string s:fselected){
            query=query+','+s;
        }
        query=query + ' from ' + selectedobj;
        mydata=database.query(query);
    }
}
i need to get only the first 4 fields for any object selected from a dropdown, and the records with the selected fields and respective notes and attachments should get displayed....
hiii,
           my requirement is when i select the required object fom dropdown and click "add" button, i have to get the list of fields of that particular object with checkboxes. when i checkin some fields like phone, name and all then i need to get all the records of that object with the selected field values. i have a program regarding this. but the thing is its not working for custom objects. it is giving some error... and i want to improve my program so that if i checkin and click " view report" button, i have to get the records of that particular object with selected fields and the list of notes and attachments (if present) for all records of that selected object...
 
here is my code

vf page:
-----------
<apex:page controller="objectController">
<apex:form > 
      <apex:pageBlock >
          <apex:pageBlockSection title= "select the objects below">
<apex:pageBlockSectionItem >
                  <apex:outputlabel value = "Object Names :" /> 
                      <apex:actionRegion >      
                           <apex:selectList value="{!selectedObject}" size="1">
            <apex:selectOption itemValue="Account" itemLabel="Account" />
            <apex:selectOption itemValue="Contact" itemLabel="Contact"/>
            <apex:selectOption itemValue="Lead" itemLabel="Lead" />
            <apex:selectOption itemValue="report" itemLabel="report" />
            <apex:selectOption itemValue="campaign" itemLabel="campaign" />
            <apex:selectOption itemValue="merchandise" itemLabel="merchandise" />
            <apex:selectOption itemValue="invoice" itemLabel="invoice" />
            <apex:selectOption itemValue="case" itemLabel="case" />
            <apex:selectOption itemValue="solution" itemLabel="solutions" />
            <apex:selectOption itemValue="document" itemLabel="document" />
            <apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
            <apex:actionSupport event="onchange" rerender="myFields"/>
                            </apex:selectList>
                          <apex:commandbutton value="add"/>
                     </apex:actionRegion>                         
              </apex:pageBlockSectionItem>
               </apex:pageBlockSection>
          
<apex:pageBlockSection title ="these are the fields....">
              <apex:pageBlockSectionItem >
                      <apex:outputlabel value="Field Names :"/>   
                      <apex:outputPanel id="myFields">   
                        <apex:actionRegion >  
                           <apex:selectCheckboxes value="{!selectedField}">
    <apex:selectOptions value="{!ObjectFields}" />
    </apex:selectCheckboxes>
      <apex:commandbutton value="view report"/>     
                        </apex:actionRegion>      
                     </apex:outputPanel>
              </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
             
      </apex:pageBlock>
  </apex:form>
</apex:page>

apex:
------------
public class objectController
{
    public Map <String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
    public String selectedObject {get; set;}
    public String selectedField {get; set;}
    
    public List<SelectOption> getObjectNames() 
    {
        List<SelectOption> objNames = new List<SelectOption>();
        List<String> entities = new List<String>(schemaMap.keySet());
        entities.sort();
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     public List<SelectOption> getObjectFields() 
     {
         
            Map<String, Schema.sObjectType> schemaMap = Schema.getGlobalDescribe();
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            Map<String, Schema.sObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
            List<SelectOption> fieldNames = new List<SelectOption>();
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
             
            }
            return fieldNames;
      }       
}  
i have a vf page which gives the list of fields when we select an object from dropdown. but i need to create a page so that when we select an object from drop down, and we click a button like "add", the list of fields of that particular object should get displayed with checkboxes.. if we checkin some fields, the values of that fields should be displayed 
using triggers how to get the list of remaining contacts seperated by "," in custom field created in accountobject related to contact obj 
 

I need to display the notes and attachments related list in visual force page.

  • February 02, 2012
  • Like
  • 0