This section describes some of the key exceptions observed in CPQ and describes how to deal with governor limits if the code encounters them after configuring CPQ. In general, you need to analyze logs and follow the best coding practices to resolve the errors. For more information, refer to Salesforce App Limits Cheatsheet.

Exception 1: System.LimitException: Apttus_Config2: Too many DML rows: 10001

This exception occurs when you try to perform DML operations on more than 10000 records at a time.

DML is different than SOQL. DML is the process typically used to insert, update, upsert, or delete records; SOQL is the query language used to return rows. Per the governor limits, the maximum number of records retrieved by SOQL queries is 50000. The maximum number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin is 10000.

Sample Business Use Cases

  • The Hierarchy View update job displays the Too many queries error, which has impacted the price book and display of products (products are not displayed under the correct categories on the catalog).
  • When adding items to the option group Destination Sets in CPQ Admin Console in Production, an error is received for the Bundle LOGIQ S8 R3 (ULS_PCL_GI_0025).

Best Practices

  • A separate class implementing the Database.Batchable interface allows CPQ to handle DML in batches of records.
  • You can use <apex:actionPoller> in a Visualforce page.
  • If the trigger has DML functionalities for many rows (more than 10000), it must be in Batch Apex.

Exception 2: Visualforce Remoting Exception: Apex heap size too large

Salesforce enforces an Apex Heap Size Limit of 6 MB for synchronous transactions and 12 MB for asynchronous transactions.

The Apex heap size too large exception occurs when too much data is being stored in memory during processing. The limit depends on the type of execution (for example, synchronous or asynchronous calls).

Sample Business Use Cases

When the constraint rule maintenance batch job is executed from the Maintenance tab, it runs erroneously. Especially for constraint rules with Product Field Set in Product Scope in constrain rule condition and criteria, a lot of memory is consumed to create Product Constraint View records. Eventually the batch crosses Salesforce governor limit of 12 MB memory usage per asynchronous transaction and skips creating views for some rules.
The following exception occurs: Apex heap size too large: 13808228.

The Apex governor limits for heap size are as follows:

Total Heap Size
Synchronous Limit6 MB
Asynchronous Limit12 MB
Email Services32 MB

Best Practices

  • Do not use class-level variables to store a large amount of data.
  • Utilize SOQL For loops to iterate and process data from large queries.
  • Construct methods and loops that allow variables to go out of scope as soon as they are no longer needed.
  • Reduce the limits to the SOQLs and use transient keyword.

Exception 3: System.LimitException: Apex CPU time limit exceeded

Salesforce has a timeout limit for transactions based on CPU usage. If transactions consume too much CPU time, Salesforce terminates the execution of long-running transactions. The maximum CPU time on the Salesforce servers is 10000 milliseconds for synchronous transactions or 60000 milliseconds for asynchronous transactions.

Sample Business Use Cases

  • Users could not see products in the cart after executing the Category Maintenance job.
  • Users cannot execute the Update Product Constraints View and they receive an error - Apex CPU Time Limit Exceeded.
  • Users encountered a "system.LimitException" error when they had more than 100000 products, defined a constraint rule with 98 condition products, and configured product scope as FieldSet. If there are a large number of fields defined in that Product Field Set, user encountered the error. 

Best Practices

  • Remove unnecessary code and loops.
  • Use collections (Set, Hashmap, or List) efficiently.
  • Avoid using a loop within another loop.
  • SOQL query should be indexable.
  • Avoid unnecessary re-initialization of variables.
  • Use Aggregated SOQL (database operations are not counted in this limit, so avoid arithmetic operations in Apex).
  • Check how much time workflow rules and process builders take.

In CPQ

  • Define the following settings before running the Category Maintenance job.
    APTS_UpdateViewUseDmlLimit = true
    APTS_UpdateViewProductBatchSize = 50
  • Optimize the constraint rule of ProductScope = Product Field Set to a lower number (this always breaks because of Salesforce limit).
  • Avoid using many Custom Formula fields.
  • To avoid "system.LimitException" error, create multiple constraint rules to reduce the number of condition products in a single constraint rule. Also, lower the number of fields in the Product Field Set.

Exception 4: System.LimitException: Too many query rows: 50001

There is a limit to the number of records that that can be retrieved by the SOQL query, which is 50000 records. The 50000 limit is an overall per-transaction limit and not a per-query limit. If you attempt to query the more than 50000 records, you will get an exception.

Sample Business Use Cases

  • When running Category Maintenance, the following error occurs: Apttus_Config2:Too many query rows: 50001
  • When trying to add more than 100 products from Catalog, CPQ displays a message: Apttus_Config2:Too many query rows: 50001
  • When there are more than 400 lines added to the quote, the performance of CPQ is impacted.

Best Practices

  • Use Batch Apex, in which the 50000 limit counts for each batch execution.
  • These limits count for each Apex transaction. For Batch Apex, these limits are reset for each execution of a batch of records in the execute method.
  • Limit the results by adding more criteria or using a LIMIT 50000 statement in SOQL.

In CPQ

  • All constraint conditions or actions must have a narrow search.
  • Avoid using Product field set.

Exception 5: System.LimitException: Too many SOQL queries: 101

This exception occurs when you exceed the SOQL queries governor limit. You can run up to a total of 100 SOQL queries in a single call or context.

Sample Business Use Cases

  • If you finalize a cart that has 50 to 60 ramp lines, the cart stops responding.
  • Each product added to the cart has a constraint rule. When you add 90 line items to the cart, constraint rules fail to work.

Best Practices

  • Change the code by following the Apex Code best practices so that the number of SOQL queries triggered is less than 100.
  • Change the context; use the @future annotation, which runs the code asynchronously.
  • Ensure that you do not have a recursive loop calling a SOQL.
  • Follow Apex Code key principals while writing triggers and bulk requests.
  • Do not perform any DML or CRUD operation inside a For loop.