SAP Knowledge Base Article - Public

3661058 - Cannot add products via AddItem() in scripting

Symptom

  • Error thrown when trying to add item with snippet AddItem()
    Error message: "KeyError: The given key was not present in the dictionary."

Environment

SAP CPQ

Reproducing the Issue

  1. Have a script which has AddItem() in in, as for example:
    for x in container.Rows:
      Log.Info(str(x.GetColumnByName('ID').Value))
        Quote.AddItem(x.GetColumnByName('ID').Value)
  2. Attach it to any product, so when the product is added to quote, the error happens.

Cause

The issue happens when products are attempted to be added using the script, and they belong to an inactive category. So, when a product is added to the quote through Quote.AddItem(), a reverse catalog search is triggered to locate the product. However, due to the product's association with an inactive category, it cannot be found. Consequently, its properties fail to load, leading to a 'key not present in dictionary' error.

Resolution

To resolve this issue, verify whether it is possible to move the products to a different and active category. Consider enabling the existing category that contains the products intended to be added using the script. This will ensure proper loading of product properties and prevent the 'key not present in dictionary' error.

Keywords

CPQ, key, dictionary, add, quote, script, error, additem, catalog, product , KBA , CEC-SAL-CPQ , Sales Cloud CPQ , Bug Filed

Product

SAP CPQ 2025