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 with field values from checkins of field types like name, phone, billingcity etc...

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