Catalog UI Policy Script only executes once

Brian Hofmeiste
Kilo Guru

In the Self-service portal I'm allowing the user to select a laptop from a select lookup box.  Once they select it, I have a UI policy script execute which updates the rich text label below the select lookup box.  This works fine but only works once.  If they select a different item in the lookup box the script doesn't execute again.  If they move it back to "--none--" and then make another selection it works again. 

 

It appears the UI policy conditions only check when the user changes it from nothing to something.  If you change from something to something it doesn't fire.  Any ideas?

2022-12-11_05-47-34.png

 

2022-12-11_05-47-07.png

 

 

 

function onCondition() 
{
	var choiceValue = g_form.getValue('which_laptop');
	var gr = new GlideRecord('pc_product_cat_item');
	gr.addQuery('short_description', choiceValue);
	gr.query(findRecord);
	function findRecord(gr)
	{
		while (gr.next()) 
		{
			g_form.setLabelOf('selected_item',gr.description);
		}
	}
}

 

1 ACCEPTED SOLUTION

RaghavSh
Kilo Patron

Put your code in an on change client script , where your field should be your lookup select box.


Raghav
MVP 2023

View solution in original post

4 REPLIES 4

RaghavSh
Kilo Patron

Put your code in an on change client script , where your field should be your lookup select box.


Raghav
MVP 2023

Hi there!  Client scripts are attached to tables correct?  Which table would I connect the script to if someone is trying to order an item in the portal like I've shown above?

It will be a catalog client script attached to the catalog item in which the UI policy exists.


Raghav
MVP 2023

You're the best!  Thanks this worked, I can't believe I didn't think of it.