How To Parse the CPQ Configuration Pipeline Viewer

March 15, 2024 | 2 minute read
Text Size 100%:

Introduction

The CPQ Configuration Pipeline Viewer, which is only visible to FullAccess users, is useful for administrators to confirm configuration setup and behavior when implementing or maintaining system configurations.

The Pipeline Viewer is a valuable check on model's current attribute values and applicable rules. Here's some example uses:

  • Check if a rule has fired through AJAX
  • View a list of the currently active rules
  • View all attributes that are inputs to currently active rules

Also for those of you who are using the CPQ Pricing Engine, Pricing Rules are included in the Pipeline Viewer so you can verify the setup of pricing and identify if rules are applied correctly.

Parsing the Pipeline Viewer Output

The Pipeline Viewer contains some valuable information, but how can you use it your functional testing program?

If you're already working with the CPQ REST APIs to manage your commerce process, the answer is easy - use the Commerce pipelineViewer API to display the rules that are in effect for the current Commerce process.

For customers who need information about the Configuration Pipeline Viewer, you can get this information saved and parsed without too much effort. Here's how:

The first step is to save the pipeline viewer output to disk. Once you've done that use the below Python script to read the HTML into a Pandas dataframe and output to either CSV or JSON.

The saved Pipeline Viewer HTML contains a few nested tables and is a bit awkard without some help. The pandas read_html() function is a simple way to read an HTML table into a DataFrame and is a perfect fit for our needs.

import pandas as pd

# Set variables for file name and an additional attribute delimiter
file_name = r'Your File Name Here'
delimiter = '|'

# Open file and replace <br> within input attributes with delimiter.
# The <br> element is used to separate attribute values in the HTML table.
with open(file_name, mode='r', encoding='utf-8') as file:
    data = file.read().replace('<br>', delimiter)

# Read HTML file, look for table with 'Rule Name' included
df = pd.read_html(data, match='Rule Name')
# How many tables are there?
print(f'Total tables: {len(df)}')

# Drop first row, nothing of value here
df = df[1].iloc[1:]

# Set column names
df.columns = ['name', 'type', 'level', 'attrs']

# Check output
print(df.head(10))

Depending on how you want to output the data, choose one of the next steps. First to output to JSON:

# Add order column to increment rule evaluation order. Needed if saving to JSON.
df.insert(0, 'order', range(1, 1 + len(df)))

# Save to JSON file
df.to_json('cpq-pipeline-viewer.json', orient='records')

Next, the output to CSV is simpler:

# Save to CSV file
df.to_csv('cpq-pipeline-viewer.csv', index_label='order')

Once you've saved your CSV or JSON file, you can integrate the output into your functional testing program.

Summary

It's that easy to get your Configuration Pipeline Viewer output into an easy to use JSON or CSV format. Happy hunting!

~sn

Shea Nolan


Previous Post

CISO Perspectives: Using the Oracle Cloud Infrastructure (OCI) CIS Landing Zone for Security & Compliance

Leia Manchanda | 3 min read

Next Post


Getting transformation done right; observations from the field.

Nick Goddard | 10 min read