I want to create a picklist of all objects of my salesforce org. by the help of AJAX, without using apex controller.I want to achive this functionality by VF page only.


2 Answers 2


This can be done using the describeGlobal() method from the AJAX toolkit:

<apex:page title="Object List">

    <apex:pageBlock title="Object List">
        <apex:pageBlockSection columns="1">
                <label for="object-list">Object List</label>
                    <!-- select list would be generated dynamically -->
                    <div id="selectContainer"></div>

    <!-- getting the session -->
    <script type="text/javascript">
        var __sfdcSessionId = '{!GETSESSIONID()}';

    <!-- script required for making AJAX call -->
    <script src="../../soap/ajax/37.0/connection.js" type="text/javascript"></script>
    <script type="text/javascript">     

        // fetch the container div
        var myDiv = document.getElementById("selectContainer");

        // create and append select list
        var selectList = document.createElement("select");
        selectList.id = "object-select";

        // make an AJAX call
        var result = sforce.connection.describeGlobal();

        // create and append the options
        var sobjects = result.getArray("sobjects");
        for (var i=0; i<sobjects.length; i++) {
            var option = document.createElement("option");
            option.value = sobjects[i].name;
            option.text = sobjects[i].label;



Note here, you would need connection.js file which is a Standard Salesforce JavaScript file.


You can use apex remoting for that, so you will be calling an apex class from your ajax method, but It's impossible to do that without calling apex, all you need to do is create a class that calls schema.getDescribe to get a map with all the objects in your org, then just send it back to your ajax as a JSON and convert it to a picklist

  • 2
    Nothing is impossible my friend!
    – Raul
    Sep 15, 2016 at 13:01
  • .Thanks its really appreciating.If I want to fetch all the records, on selection of each object in the Active widget then what should be my approach.
    – guru
    Sep 19, 2016 at 9:41
  • 1
    Well, of course it is if you want to keep the Salesforce MVC pattern. Nice solution by the way!
    – Agusnovak
    Sep 19, 2016 at 12:08

Not the answer you're looking for? Browse other questions tagged .