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

How to fetch all data types in picklist


How to fetch all data type in picklist in vf page 
Khan AnasKhan Anas (Salesforce Developers) 

I trust you are doing very well.

Below is the sample code which I have tested in my org. Kindly modify the code as per your requirement.

<apex:page controller="DataTypePicklistC">
    <apex:form > 
        <apex:pageblock title="Data Types in Picklist">
            <span>Data Type: </span>
            <apex:selectList multiselect="false" size="1" value="{!selectedField}">
                <apex:selectOptions value="{!OppNames}"/>
                    <apex:actionSupport event="onchange" action="{!showField}"/>
            <apex:pageblockbuttons >
                <apex:commandButton value="Cancel"/>

public class DataTypePicklistC {
    String objType='Account';
    public List<selectOption> oppflds;
    public String selectedField {get;set;}
    public List<selectOption> getOppNames() {
        Set<selectOption> myset = new Set<selectOption>();
        oppflds = new List<selectOption>();
        myset.add(new selectOption('--none--','--none--'));
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType leadSchema = schemaMap.get(objType);
        Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
        for (String fieldName: fieldMap.keySet()) {
            //get all the fields label for Account Object
            String fieldLabel = fieldMap.get(fieldName).getDescribe().getLabel();
            //get data types for each fields
            Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType();
            System.debug('Data type -> ' + fielddataType);
            string fieldType = String.ValueOf(fielddataType);
            myset.add(new selectOption(fieldType,fieldType));            
        return oppflds;
    public void showField(){

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas​
Hello, I have requirement like that. Create field from vf page by selecting data type and created field display as input in vf page. For example from pick-list If selected text field with label name this field I want display on another page as a input field.
Ajay K DubediAjay K Dubedi

Below code can fullfill your requirements. Hope this will work for you.

Visualforce Page:

<apex:page standardController="Account" extensions="AccountDeleteWrapperCLs">

    <apex:form >

        <apex:pageBlock >

            <apex:pageBlockTable value="{!accWrap}" var="acc">

                <apex:column headerValue="select">

                    <apex:inputCheckbox value="{!acc.checkbox}"/>


                <apex:column headerValue="id">

                    <apex:outputField value="{!}"/>


                <apex:column headerValue="Name">

                    <apex:outputField value="{!}"/>


                <apex:column headerValue="Industry">

                    <apex:outputField value="{!acc.accObj.Industry}"/>



            <apex:pageBlockButtons >

                <apex:commandButton value="delete" action="{! deletecheckedRecs}"/>






public class AccountDeleteWrapperCLs{
    public list<Account> Acclist{get;set;}

    public ID currentPageID;

    public list<DeleteExample> accWrap {get;set;}

    public AccountDeleteWrapperCLs(ApexPages.StandardController controller) {

        accWrap = new list<DeleteExample>();

//Querying the Student records

        Acclist = [select id,name,industry from account];

//Iterating through all the records of the student object

        for(integer i =0;i<Acclist.size();i++){

//Creating a new Object of InnerClass

            DeleteExample conObj = new DeleteExample(false,Acclist[i]);




//Method to delete the selected records

    public pagereference  deletecheckedRecs (){

//Iterating through the list

        for(integer i=0;i<accWrap.size();i++){

//Fetching data of the selected records

            if(accWrap[i].checkbox == true){

//deleting student records based on lists index

                delete accWrap[i].accObj;



// create visualforce page with name  deleteWrapperExample

        pagereference ref = new pagereference('/apex/AccountDeleteWrapperPage');


        return ref;


//Inner  Class

    public class DeleteExample{

        public boolean checkbox{get;set;}

        public account accObj{get;set;}

        public DeleteExample(boolean checkbox,account acc)


            checkbox = checkbox;

            accObj   = acc;




Please mark this as best answer if this solves your problem.

Thank you
Ajay Dubedi