Trouble Resetting Conditional Subcategory Fields in Service Catalog Item Form

Sysop
Tera Contributor

Hello,

 

I'm currently developing a Service Catalog form in ServiceNow and have come across a challenge. First off this is a record producer.  My form has a field named 'u_request_type' (a drop-down list with choices, one of which is 'AllyDVM Operational Comms') and another field named 'ally_subcategory' (also a drop-down list with multiple choices).

 

My objective is:

 

If the user changes the selection in 'u_request_type' away from 'AllyDVM Operational Comms', to another answer, I want the 'ally_subcategory' field to reset back to 'none', meaning it should not retain the previous selection. On the variable form for 'ally_subcategory' under "Type Specifications" I do have the "include none" box checked and --None-- is a selectable option.

 

To achieve this, I tried implementing a Catalog Client Script. Here's the script I used:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    if (newValue != 'AllyDVM Operational Comms') {
        producer.ally_subcategory = '';
    }
}

 

 

Despite this, the script doesn't seem to be working as I expected. The 'ally_subcategory' field still holds onto its prior selection when 'u_support_type' is switched away from 'AllyDVM Operational Comms'. 

Here are some screenshots.

Sysop_0-1689961308240.png

 

 

Sysop_1-1689961336407.png

 

 

Sysop_2-1689961355545.png



Sysop_3-1689961382149.png

 

 

5 REPLIES 5

Community Alums
Not applicable

Hi @Sysop ,

There are multiple ways to achieve this. Apart from that simple one is configuring UI policy. Please follow further steps:

  1. Configure a UI Policy:
    - Open your Record producer
    - Go to the "Catalog UI Policies" related list.

    - Click "New" to create a new UI Policy.
    - Provide a meaningful short description

    - Catalog condition -> u_request_type [is Not] AllyDVM Operational Comms
    Applies on a Catalog Item view = true and Reverse if false = true

    - In the Script section, make 'Run script = true' and paste the below script in Execute if true field:

 

function onCondition() {
    g_form.setValue('ally_subcategory', '');
}

- Save
PrasadS_0-1689963409949.png

 

 

PrasadS_1-1689963451806.png

 

If this helped you in any way, please hit the like button/mark it helpful. So it will help others to get the correct solution.

regards,
Prasad

Prasad,

 

Thank you for your reply.  Unfortunately this did not seem to work.  Here are screenshots of your instructions that I followed.

 

Sysop_0-1690230761434.png

 

Sysop_1-1690230791741.png

 

Any ideas on why this doesn't seem to be working would be greatly appreciated.

Community Alums
Not applicable

@Sysop , try making onLoad = false in ui policy. Everything else seems fine 🙂

Prasad,

 

That didn't seem to work either.  I'm going to open a support ticket with ServiceNow because it does seem like this should be working.  Thank you for your help. Anything further you would try?