Prices not updating in cart for Lookup variables

brian_
Tera Guru

I think this may be a bug but wanted to check with other community members to see if anyone else is experiencing this. We're using Lookup varibles (both Select and Multiple Choice) and have defined prices for the options. The prices do display properly inline with the option, and when you select the option, the displays properly update on other choices to reflect the current selection.

Option 1

Option 2 [add $100]

-selection Option 2-

Option 1 [subtract $100]

Option 2

This part works great, however the cart price never updates. Using a non-Lookup variant of the variables (standard Select Box or Multiple Choice) the behavior is as expected. Display values update AND the price is updated in the cart.

Any ideas?

pricefail.png

This blog post utilizes Lookup Select Box with pricing implications and it appears to work properly

Mini-Lab: Service Catalog - Building a Custom Choice Table

We are on Geneva Patch 7

1 ACCEPTED SOLUTION

A coworker figured out the root cause. This is not at all a bug and was a matter of our configuration.



The value of the lookup field should be set to sys_id or a unique value. I was setting it to a field in the table that was not necessarily unique. After changing it to be sys_id, everything works as expected.


View solution in original post

5 REPLIES 5

Shay Faingold
Mega Expert

Hi Brian, Strange thing indeed. Will you be able to add to your item list (sc_cat_item.list) the field: Ignore Price and see what the value for that Item? If its True, it means you somehow changed that value to True in other Item and just duplicated the item - this should really be False for all priced Items. If its False, will have to think about something else 🙂 Waiting for your reply on this, Shay


Good idea. But it is set to false


yogesh15dd
Tera Guru

Hi Brian,



As far i know, the below script part under the UI macro (sc_order_item_price_quantity) from OOTB, will take care of calculating/updating the price.



The particular line is : (onchange="orderItemWidget.calcPrice()")



  <span id="quantity_span">


  <g:evaluate expression="var choice_list = GlideScriptChoiceList.getChoiceList('sc_cart_item', 'quantity');" />


  <select id="quantity" class="form-control" onchange="orderItemWidget.calcPrice()" style='${quantity_style}'>


  <g:options choiceList="${choice_list}" choiceValue="${jvar_cart_item.quantity}" />


  </select>


    </span>



However, not sure you would like to follow this approach, you many convert the field from 'choice list' to 'text' field, then catalog price calculation will work


properly based on the input quantity values you give.



Check here


https://community.servicenow.com/message/921169?et=watches.email.thread#921169



Note: For this you will have to create a new UI macro, as you wont be able to edit the read only UI macro: sc_order_item_price_quantity.


brian_
Tera Guru

I've figured out the cause. I'm using ref qual with javascript to concatenate values into an encoded query string:



javascript:'u_phone='+current.cat_item.sys_id+'^u_companyLIKE'+current.variables.requested_for.company+'^u_option=color'


Even just doing javascript: 'u_option=color' without any concatenation or looking to values causes this behavior. Removing that ref qual causes it to work properly, although our options list isn't filtered. The blog post I referenced in my initial post uses a script include for this, so I will be moving this behavior into a script include. I'll update this post with my results.