One of My Form Variable is Showing as Mandatory on the RITM Even Though it isn't on the Form

cwolfe01
Giga Guru

I have a form with the following variables:

  • asset_tags(List Collector)
  • asset_is_not_listed(CheckBox)
  • asset(Single Line Text)

The variables asset_tags & asset_is_not_listed are only shown to the user when they choose an option other than none for the variable request_type. When asset_is_not_listed is checked, asset_tags is made non-mandatory, and asset is made visible & mandatory. 

 

When I go to submit a request where asset_is_not_listed is checked, the asset_tags variable is still showing as mandatory on the RITM even though it is made non-mandatory on the form. On the RITM, I can uncheck, then recheck asset_is_not_listed, and then asset_tags will be marked non-mandatory, but I want it to be non-mandatory on submission. How can I fix this?

1 ACCEPTED SOLUTION

Dumb me....!!

 

You can put second ui policy as it is previously.

Make mandatory  as leave alone for UI policy action of asset tags from first Ui policy.

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

6 REPLIES 6

Vishal Birajdar
Giga Sage

Hi @cwolfe01 

 

Can you share Ui policy or client script you have configured and also some screenshot if possible..

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Ratnakar7
Mega Sage
Mega Sage

Hi @cwolfe01 ,

there might be an issue with the way the UI policy or client script is handling the visibility and mandatory attributes of the variables when asset_is_not_listed is checked.

To ensure that asset_tags becomes non-mandatory when asset_is_not_listed is checked and vice versa, follow these steps:

  1. UI Policy: Review the UI policy that controls the visibility and mandatory attribute of asset_tags and asset. Make sure the conditions are correctly set to evaluate the value of asset_is_not_listed. The UI policy should set the attributes as follows:

    • asset_tags: Visible (true) and Mandatory (false) when asset_is_not_listed is checked.
    • asset_tags: Visible (true) and Mandatory (true) when asset_is_not_listed is unchecked.
    • asset: Visible (true) and Mandatory (true) when asset_is_not_listed is checked.
    • asset: Visible (true) and Mandatory (false) when asset_is_not_listed is unchecked.
  2. Client Script: If you're using a client script to control the attributes, make sure it's working correctly. Debug the script to ensure it's correctly setting the visibility and mandatory attributes based on the value of asset_is_not_listed.

    Here's a JavaScript example for reference:

    function onChange(control, oldValue, newValue, isLoading, isTemplate) {
        if (isLoading || newValue === '') {
            return;
        }
    
        var assetIsNotListed = g_form.getValue('asset_is_not_listed');
        g_form.setDisplay('asset_tags', assetIsNotListed === 'true');
        g_form.setMandatory('asset_tags', assetIsNotListed === 'false');
        g_form.setMandatory('asset', assetIsNotListed === 'true');
    }
    

 

Thanks,

Ratnakar

Hi there. 

 

On the variables tab, asset_tags, asset_is_not_listed, and asset are all marked as active & hidden.

 

My first UI policy is shown below:

Screenshot 2023-09-29 141108.png

 

My second UI policy is shown below:

Screenshot 2023-09-29 131644.png

 

No other UI policies take any action against asset_tags, asset_is_not_listed, or asset.

Hi @cwolfe01 

 

I guess there is a contradiction in asset tag ui policy action.

In second ui policy , for asset tags ui policy action make mandatory as leave alone.

Then it will work correctly.

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates