Salesforce CPQ – Dynamic Bundle with Product Search Plugin

Option is missing entry in selected pricebook => XXXXXXXXXXXX: YYYYYYYYYYYYYYYY

Odd Messages from CPQ

Related Content

Salesforce CPQ – Product Search Plugin

Salesforce CPQ – Product Search Plugin – Extended Example


Scenario

Let us look at a scenario where we are employing Dynamic Bundle configuration in concert with the Product Search Plugin. There is an odd behavior that can happen here, and it isn’t quite intuitive why it happens.

Steps to Reproduce:

  1. In Dynamic Bundle Feature, click ‘Add Options’
  2. Select an option as normal
  3. Save
  4. Return to configurator screen to find table headers, but no row record for the selected Product.

If we look at the browser console, there are few interesting things to note. First is a console message as follows:

But we know that the Product selected has a Pricebook Entry record, otherwise it wouldn’t have shown for selection in the first place (and we’ve checked and confirmed the record itself). So this message seems to be untrue.

When looking at the html it gets a little stranger, as the row for the Product is there but hidden.

If we Save anyways, and then return into the configuration the row will then appear as the Save action has created the Quote Line. That said, this is obviously unacceptable behavior for the user as they cannot tell that they’ve actually added the Product. So we need to figure out what to do here.


Solution

The problem here is actually coming from the Product Search Plugin, even though the PSP is not running on the configurator page itself, which is why we didn’t think to check into that possibility first. When you use the Product Search Plugin, you’re telling the package that you’ll return the object attributes that it needs to perform subsequent functions. In this case, the PSP needs to return not only the Pricebook Entry records themselves, but also must include the UnitPrice value in that record. Therefore, the Select clause built out in the search method of the PSP must include the UnitPrice field. This field is shown in the documentation, but it’s never stated to be required.

Original start to the SELECT statement – this causes error:

String pbEntryQuery = 'SELECT Id'; 

Updated start to the SELECT statement – this fixes error:

String pbEntryQuery = 'SELECT Id, UnitPrice'; 

Now when we go through the same reproduction steps, the selected product shows correctly, and problem solved!

I don’t expect many will have experienced this due to copy/pasting from the documentation, but if you’ve made some significant adjustments and unknowingly caused this issue, hopefully this post will save you some pain.


Wrapping Up

Thanks for reading, and let me know if this saves you any grief. Credit to Krishna Katve and Amruta Sinha for uncovering this issue.

Leave a Reply

Your email address will not be published. Required fields are marked *