The CreatorCon Call for Content is officially open! Get started here.

Overriding defualt price calculator on Catalog Items

sebbelcher
Kilo Explorer

Hi,

I am trying to override the default CatalogPriceCalculator for specific catalog items. I have a service which has some complex pricing, depending on options selected from Lookups in the form, the base price needs to be modified with both an 'adder' which is what normally happens if I pricing lookup is selected - but I also need to be able to apply a multiplication modifier to the price based on a value of the lookup field. (i.e. it costs 20% less to host an application in location A compared to location B - I want to multiply the catalog price by 0.8 if location B is selected)

The Wiki suggests extending the CatalogPricingCalculator to override the default function - I have written this override function for calcPrice - but how do I invoke this class for the specific catalogue items?

Thanks,
Seb

5 REPLIES 5

benn23
ServiceNow Employee
ServiceNow Employee

May be overkill but I've used a hidden select variable in the past to manipulate the price. What happens is someone selects something, a calculation is done (in my case we had a supporting table that held combinations of things which included a price), and a new value is inserted via script include into the hidden select field's options... The user has no idea that they're actually creating a new record in the question_choice table for that hidden select field. Then that drives the price.


sebbelcher
Kilo Explorer

I find it odd that this is so hard to get an answer on, when the Wiki and the script comments for CatalogPriceCalculator both indicate that this is the recommended way to do custom price models.

How about a more generic question then: How do you add a server-side script include to specific catalogue items?


Isn't Server-Side script includes essentially a business rule? I'm thinking on the sc_cart_item table on update, but I'm not sure how that will help.


MoustafaEid
Kilo Explorer

I have submitted a ticket on the HI server and got no where. Even though the agent was helpful, he couldn't give me more specific details, he gave me those links instead:

http://wiki.servicenow.com/index.php?title=Useful_Catalog_Scripts
http://wiki.servicenow.com/index.php?title=GlideAjax
http://wiki.servicenow.com/index.php?title=Category:GlideAjax_Script_Includes
http://wiki.servicenow.com/index.php?title=Creating_a_Catalog_Client_Script

I am not sure if what we're trying to achieve can be done. It seems that the only way that the price is updated is by adding up the pricing for each of the variable selections of an item. A good way to influence the pricing is maybe having a free-form text field that you can add the dynamic pricing to with a client script, and the value of the field should affect the price when it gets recalculated. However, I don't see a "Pricing Implications" option on text fields that allows values in text fields to affect pricing of an item.