Dynamically add option, price to select box with client script

vw1
Giga Contributor

Hi all

 

I am working on a catalog client script (onChange script), which dynamically changes select box's options, based on requester's role.

If a user is an asset manager, I would like to add an option called "Keyboard", with a price. (Similar to what is shown below)

find_real_file.png

I was going through documentations of g_form, where I found the below function:

addOption(String fieldName, String choiceValue, String choiceLabel, Number choiceIndex)

 

I do know that I could set that in the "Question Choices", but if the user changed it to 

Does anyone know if there is a way to add price to the newly added option? 

 

Thank you.

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

Currently there isn't a way to set a price on a dynamic option created via a script. The only way I've found to accomplish this is to use a lookup select box with a custom table where you can configure all of the options and include a value, label and price and then display the options you want based on a reference qualifier.

Wish there was a better answer!

If this was helpful or correct, please be kind and click appropriately!

Michael Jones - Proud member of the CloudPires Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

2 REPLIES 2

Chander Bhusha1
Tera Guru

Hi V.W,

So you need to update the price based on the select box choice or is it only for the choice label.

If yes, then you can follow this link.

 

This link will help you :

https://community.servicenow.com/community?id=community_question&sys_id=a9c1df6ddbdcdbc01dcaf3231f96...

 

Mark helpful and correct if it helps.

Thanks,

CB

Michael Jones -
Giga Sage

Currently there isn't a way to set a price on a dynamic option created via a script. The only way I've found to accomplish this is to use a lookup select box with a custom table where you can configure all of the options and include a value, label and price and then display the options you want based on a reference qualifier.

Wish there was a better answer!

If this was helpful or correct, please be kind and click appropriately!

Michael Jones - Proud member of the CloudPires Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!