function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
munna123munna123 

how to get the records of an object with selected checkin fields

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;
      }
}