In the product object, I created a custom field that for inserting the Terms and Conditions. The Terms and Conditions is more then 20000 characters. I also created a function that for previewing the quote in PDF format or send the quote to the client email address. However, the user got the time limit exceeded error when trying to preview the quote. I've tested that I believe that it's about too many characters in the custom field.

Maybe Salesforce query the data for too long?

This is the query for loading the data. "Terms_And_Conditions_Eng__c" is the custom field that it will contain more than 20000 characters.

this.oQuote = [SELECT Opportunity.AccountId, Opportunity.Account.Region__c, OpportunityId,
            Opportunity.OwnerId, Opportunity.Owner.Name,
            Opportunity.Account.Avus_Account_Number__c, Opportunity.Account.Duplicate_AVUS_Reference__c, 
            Opportunity.Account.BillingStreet, Opportunity.Account.BillingCity, 
            Opportunity.Account.BillingPostalCode, Opportunity.Account.BillingState, 
            Opportunity.Account.Phone, Opportunity.Account.Fax, Opportunity.Account.OwnerId, 
            Opportunity.Account.Owner.Name, Opportunity.Account.ParentId,
            Promo__r.Id, Promo__r.TermsConditions__c, Promo__r.TermsConditionsFr__c,
            Promo__r.Name, Promo__r.French_Name__c, Promo__r.End_Date__c,
            (SELECT PricebookEntry.Product2.Id, PricebookEntry.Product2.Name, 
                    PricebookEntry.Product2.Product_Type__c, PricebookEntry.Product2.Product_Description_EN__c,
                    PricebookEntry.Product2.Billing_Frequency__c, PricebookEntry.Product2.Billing_Type__c,
                    QuoteId, Quantity, ListPrice, UnitPrice, Line_Discount__c, TotalPrice, Start_Date__c, End_Date__c,
                    Time_Discount_Unit__c, Time_Discount_Week_Duration__c, Time_Discount_Month_Duration__c, 
                    FROM QuoteLineItems),
            (SELECT Custom_Terms_And_Conditions__c, Custom_Terms_Conditions_Approved__c FROM Order_Additional_Info__r)
            FROM Quote
            WHERE Id =: this.QuoteId];
  • 1
    i just tried with my custom quote pdf generator using a RTF field with over 25000 characters and the fetch from database and pdf renderer in VF works just fine.
    – cropredy
    Jun 27, 2014 at 23:32
  • 1
    What happens if you just render the PDF in a new window as a preview? It sounds like you controller does several things. I suspect you need to isolate the source of the problem. Posting the code would be very helpful in diagnosing the source of your problem. If it previews w/o problems, your problem is most likely elsewhere.
    – crmprogdev
    Jun 28, 2014 at 3:50
  • I've updated the post with the query syntax.
    – R.Spark
    Jun 29, 2014 at 3:47
  • If the above query works when you render a preview, the problem is most likely NOT with your query! Does it only time out for the user, but not for you? That could be permissions. We'll prob need to see the rest of your code in order to assist you. Promo__c should prob be Promo__r is the only other thing that pops out at me, but you get that with Promo__r.Id.
    – crmprogdev
    Jun 29, 2014 at 5:48


You must log in to answer this question.

Browse other questions tagged .