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
- Create a Global Script to add a product to Quote from a Quote Table
- Create 2 actions in the Quote Table
- Import Global Script module
- Write the same code as written in Global Script in the definition of the action
- On the Quote, select a line from the Custom Quote Table and click on the Action
- 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
- 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()
-
- Incorrect Approach:
- 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
SAP Knowledge Base Article - Public