Nov 2, 2010

Describe Limit In Apex

Governor limit for Field Describes and Picklist Describe is increased from 10 to 100.


This limit is mostly encountered when we are displaying more than 10 picklist on visual force page which is not binded with <apex:inputField> tag. We sometimes prefer <apex:inputText> rather <apex:inputField> to avoid field security restriction on profile level. For this if we want to display picklist values on visualforce page we have to describe picklist values. Before the last release picklist describe limit was 10 so we have to describe first 10 picklist values in one call, then hit the action function for the next 10 picklist values which decrease the performance of the page. But now the limit is hiked to 100.


Hope this info is useful.

1 comment:

  1. Hi Ankit,

    I have written a controller for entering the multiple Invoice line items. The class is running successfully, but I am getting errors in writing TestCase for the same and the testcase is getting failed. So could you please look into the below mentioned code snippet (Controller class) and guide me so that the testcase is successful.


    public class DEV_MULTIPLE_InvoiceLineEntry {

    public List ords {get; set;}
    private final Invoice__c parOrd;
    public DEV_MULTIPLE_InvoiceLineEntry(ApexPages.StandardController myController) {
    parOrd=(Invoice__c)myController.getrecord();
    ords = new List();
    // Get the Current User
    user u1 =[select id ,name,Formula_Warehouse__c from user where id=:UserInfo.getUserId()];
    //Get The DefaultwareHouse for the user
    Warehouse__c[] w1 =[select id,name from Warehouse__c where name =: u1.Formula_Warehouse__c or name = null];
    invoice__c pa =[select id,name, doctor__c from Invoice__c where id=:parOrd.id];

    // Condition to Check if Formula_Warehouse__c =null, if null Item_Warehouse__c on page is NULL
    if(u1.Formula_Warehouse__c ==null){
    Invoice_Line_Item__c LitOrd = new Invoice_Line_Item__c();

    LitOrd.Invoice_Number__c = parOrd.id;
    LitOrd.staff__c = pa.Doctor__c;
    LitOrd.quantity__c=1;

    ords.add(LitOrd);

    }
    // Condition to Check if Formula_Warehouse__c !=null, if ! null Item_Warehouse__c on page is warehouse id(only ids display names in Lookups)
    else if(u1.Formula_Warehouse__c !=null){

    Invoice_Line_Item__c LitOrd = new Invoice_Line_Item__c();

    LitOrd.Invoice_Number__c = parOrd.id;
    LitOrd.quantity__c=1;
    LitOrd.staff__c = pa.Doctor__c;
    LitOrd.Item_Warehouse__c =w1[0].id;
    ords.add(LitOrd);
    }
    }



    public void addrow() {

    // Get the Current User
    user u =[select id ,name,Formula_Warehouse__c from user where id=:UserInfo.getUserId()];
    //Get The DefaultwareHouse for the user
    Warehouse__c[] w =[select id,name from Warehouse__c where name =: u.Formula_Warehouse__c];

    invoice__c pa =[select id,name, doctor__c from Invoice__c where id=:parOrd.id];
    // Condition to Check if Formula_Warehouse__c =null, if null Item_Warehouse__c on page is NULL
    if(u.Formula_Warehouse__c ==null){
    Invoice_Line_Item__c LitOrd = new Invoice_Line_Item__c();
    LitOrd.Invoice_Number__c = parOrd.id;

    LitOrd.staff__c = pa.Doctor__c;
    LitOrd.Quantity__c=1;

    ords.add(LitOrd);
    }
    // Condition to Check if Formula_Warehouse__c !=null, if ! null Item_Warehouse__c on page is warehouse id(only ids display names in Lookups)

    else if(u.Formula_Warehouse__c !=null){

    Invoice_Line_Item__c LitOrd = new Invoice_Line_Item__c();
    LitOrd.Invoice_Number__c = parOrd.id;
    LitOrd.staff__c = pa.Doctor__c;
    LitOrd.quantity__c=1;
    LitOrd.Item_Warehouse__c =w[0].id;
    ords.add(LitOrd);

    }

    }


    public void removerow(){
    Integer i = ords.size();
    ords.remove(i-1);}

    public PageReference save() {
    insert ords;
    // PageReference home = new PageReference('/home/home.jsp');
    return(new ApexPages.StandardController(parOrd)).view();
    // home.setRedirect(true);
    // return home;
    }

    }


    You may post the solution to my Id arun@tvarana.com or arunkumar.remma@gmail.com



    Sincere Regards

    Arun

    ReplyDelete