SAP Knowledge Base Article - Public

3495594 - Quote Table Custom action - AddToQuote leading to Inconsistencies in Scripting

Symptom

When importing a global script module, that contains AddToQuote method, into a Quote Table Custom Action it is not behaving the same way as when code is directly written in Action Definition. 

Environment

SAP SALES CLOUD CPQ

Reproducing the Issue

  1. Create a Global Script to add a product to Quote from a Quote Table
  2. Create 2 actions in the Quote Table
    1. Import Global Script module
    2. Write the same code as written in Global Script in the definition of the action
  3. On the Quote, select a line from the Custom Quote Table and click on the Action
    1. If clicking on the action of global script module, for the first time, line will not get deselected and product will not be added to the quote, but if clicking again, product will be added and line will become deselected
    2. If clicking on the action with the script written in the action definition, it will work on first attempt.

Cause

Issue is caused due to Quote 1.0 Restrictions with the usage of AddToQuote() method with Quote Tables.

Resolution

  • Due to Quote 1.0 restrictions, whenever calling Scripting.IProduct.AddToQuote through scripting, CPQ is cloning Quote Tables and making new instances of it

  • To ensure that Quote Tables are properly utilized in combination with the AddToQuote method, there is a correct and an incorrect approach:

    • Incorrect Approach:
      • QT = _quote.QuoteTables["TestAddToQuote"]
        for Row in QT.Rows:
              if not Row["Selection"]:
                       continue
              ProductHelper.CreateProduct( Row["ProductSystemId"] ).AddToQuote(1)
              Row["Selection"] = False
        QT.Save()
    • Correct Approach:
      • for x in range(Quote.QuoteTables["TestAddToQuote"].Rows.Count):    
        row = Quote.QuoteTables["TestAddToQuote"].Rows[x]    
             if not row["Selection"]:        
                     continue
             ProductHelper.CreateProduct(row["ProductSystemId"] ).AddToQuote(1)
             Quote.QuoteTables["TestAddToQuote"].Rows[x]["Selection"] = False
        Quote.QuoteTables["TestAddToQuote"].Save()
  • Script should be adjusted to match above shared snippet to avoid inconsistencies during its execution.

Keywords

Custom Quote Table, Product, Quote, AddToQuote, Add To Quote, Add, Bug, CPQ , KBA , CEC-SAL-CPQ , Sales Cloud CPQ , Problem

Product

SAP CPQ 2024