Salesforce Certificate

Wednesday 17 April 2013

Display sObject Fields list in picklist of visualforce page without using controller



If you want to display picklist with any sObject field list in your visualforce page. you can do it using javascript without using Apex controller. No need to write class.

Here is the example for displaying all the field of Account in picklist.
Visualforce Page:
<apex:page>
    <apex:includeScript value="/soap/ajax/16.0/connection.js"/>
    <label id="ldfield" style="font-weight:bold">Account Fields: </label>
    <select id="selectNumber">
    </select>
     <script>
        sforce.connection.sessionId = '{!$Api.Session_ID}';
        //Global Object
        var describeResults = sforce.connection.describeSObject("Account");
        //select option list
        var select = document.getElementById("selectNumber");
        for(var i = 0; i < describeResults.fields.length; i++) {
            var fieldList = describeResults.fields[i];     
            var el = document.createElement("option");
            el.textContent = fieldList.label;
            el.value = fieldList.Name;
            select.appendChild(el);       
        }
    </script>
</apex:page>

Tuesday 2 April 2013

Too Many Query Rows 50001 & collection exceeds maximum size: 1001


Page: 

<apex:page controller="ctrlCustomcontroller" readOnly="true">
</apex:page>

If your controller does not have any DML operation than you can easily solve above two salesforce governer limits using the attribute readOnly="true" by default it's value is false.

1. Query Rows limits increased from 50001 to 1 million rows
2. collection size limits increased from 1001 to 10,000