How can I set the price of a dynamic select box variable option from a Service Catalog client script?

Stephen W_
Giga Guru

I have a variable set of 'Select Box' variables attached to a service catalog item.

I use a catalog client script to set each question and populate the choice lists.


I populate the choice lists with

g_form.addOption(<var name>, <option value>, <option label>);

 

How do I now set the price for that option?

Thanks,

 

-Stephen

14 REPLIES 14

ccajohnson
Kilo Sage

It is unclear what you are trying to do. Are you trying to set a price based upon selection, or something else? Please explain how you populate the menu choices. Is this through a look-up table, or hard-coded into the script itself. Perhaps if you show the entire script it may be helpful in understanding your intent.



Thank you for your assistance,


If select box choices are manually created, you'll have the option to set:


Price, Recurring Price, Order, Question, Text, Value.



I am setting text and value using g_form.addOption. The text and value I'm using to create these options are derived from one of many models which are associated with the Catalog Item.     Just as I added the text and value from the model to the choice, I want to add the price from the model to the choice.



My end goal with this step is to affect the catalog item's price in the cart. (As this is the out-of-the-box behavior for manually created choices)


It sounds like you are selecting the Model first which is then used to add the choices to the menu. ServiceNow has several methods of updating the price. You might want to look through these to determine the best method to match your current development efforts:


wiki.servicenow.com/index.php?title=Service_Catalog_Variable_Pricing



Thank you,


Thanks Christopher, however, I'm not sure we are communicating clearly.



You are correct that I am using a model to add choices to the catalog variable question. However, it doesn't really matter at this stage where the price comes from or even that it pertains to a model.   I am programmatically creating variable choices for service catalog select box questions.   It must be a select box because that is the only one which ServiceNow describes in the g_form documentation for dynamic choice creation.   The documentation does not, however, describe a method for updating the price from g_form. (and in fact it errors if I have a pre-existing choice with a price and switch to one of these dynamic values with a null price)



You alluded to several methods for updating the price. If you can point me in the direction of one of these methods for updating the price on a dynamically generated choice.. it would be greatly appreciated!