Remove Dependent Catalog Items in Order Guide Based on Selections

jmiskey
Kilo Sage

I have an Order Guide that I am using on the Service Portal.  It has a lot of Variable Sets and Catalog Items.  My main Order Guide has a few List Collectors.

List Collector #1 is the initially the only one visible.  Based on the values selected in it, List Collector #2 and List Collector #3 may or may not be displayed (they are initially hidden through Catalog UI Policies).  Then, based on the selections made in List Collector #2 and List Collector #3, specific Catalog Items are displayed (via Rules Base conditions).

The issue that we are having is the following.  Let's say that we made a bunch of selections, and made some errors.  So after we have made selections in List Collectors #2 and/or #3, if we then remove them, it (correctly) also removes those Catalog Items from view.  However, if the person instead decides to remove the item from List Collector #1, it will hide the appropriate List Collector #2 or List Collector #3 box, but does not hide/remove the matching Catalog Item.

So, I am trying to figure out a way to do that.  I was thinking maybe trying to do something with a Catalog Client Script, but I am having issues getting that to work (I thought maybe doing an onChange of List Collector #1), and checking to see if List Collector #2 and List Collector #3 and hidden, and if they are, be sure to clear out their values.  But I could not get that to work.

Any ideas?

Thanks

 

1 ACCEPTED SOLUTION

You should just need to paste the line of code in the 'Execute if false' field of the 'Scripts' section of the UI policy.  If the UI policy returns false, the field will be hidden, made optional, and cleared.  Just make sure 'Run scripts' is checked and 'Run scripts in UI type' is set to 'All'.

View solution in original post

7 REPLIES 7

Mark Stanger
Giga Sage

You can use 'g_form.clearValue('my_list_collector_name');' in a client script or UI policy to clear out the value of your list collectors.  You'll want to do this each time they are hidden.

jmiskey
Kilo Sage

Thanks Mark.  That is kind of what I was thinking, and trying to do in my Catalog Client Script.  I think the part that is tripping me up is how can I determine if a certain field on my form is visible or not in my script at the time the script is called?

Or maybe I need to come at that part a bit differently, and loop through the selected value in that List Collector?

What do you think?

I don't think you need to do that at all.  All you have to do is make sure that every single time you make a call to hide a field, you also clear the values at the same time.  As long as you did that every time consistently it wouldn't matter what was hidden or not.

Currently, the only thing that changes that is a Catalog UI Policy that runs on the first List Collector.  It displays the second List Collector (and makes it mandatory) when the appropriate value is selected from the first one.    I have the "Reverse if false" setting checked, so that List Collector #2 is hidden initially, by default. 

So, since this Catalog UI Policy only runs when the appropriate value is selected from the first List Collector, would I need to change how it works (or add a new one) to run the line of code you mention when that value is NOT contained in the first List Collector?