cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to read product attribute values on Quote page on CPQ?

sbslmhmt
Participant
0 Kudos
1,316

Hello experts,

Let's say we have a Quote that has two items like down below;

Selected 'Vehicle Code' for item 'SCS' on configurator;

Selected 'Vehicle Code' for item 'SLA_Y' on configurator;

We have global script which we are calling as a custom event on Quote page.

We would like to read selected attribute values of each item on this script.

Here is the example code;

for a in Quote.MainItems:
	a.Edit()
	Trace.Write('--------------->>>'+Product.PartNumber)
	Trace.Write('--------------->>>'+Product.Attr('Vehicle Code').SelectedValue.ValueCode)

Here is the trace;

PartNumbers are correct but selected values of "Vehicle Code" attributes are wrong. Second iteration also fetches first products selected attribute value.

Anyone knows why this problem occurs and how to fix it?

Best regards.

Accepted Solutions (0)

Answers (1)

Answers (1)

Sergey_L
Participant
0 Kudos

Mehmet,

I don't have enough experience to know why this isn't working for you, but I can offer some alternative methods.

I know this is stupid, but I better ask - are you sure that the value code of both of those values isn't the same? You show the display values in the drop down, but you pull the value codes.

1. If you must have the script edit the item (which isn't necessary unless you're also changing things), then you could simply use this tag:

Trace.Write(TagParserProduct.ParseString("<*VALUE(Vehicle Code)*>"))

2. If you don't have to edit the item, you can iterate through the items like so:
for a in Quote.MainItems:
	for b in a.SelectedAttributes:
		if b.Name == 'Vehicle Code':
			for c in b.Values:
				Trace.Write("Vehicle Code: " + c.Display + ", " + c.ValueCode)


Hope this helps and I hope you'll share with us what worked for you.