- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 07:57 AM - edited ‎09-29-2023 08:22 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 12:20 PM - edited ‎09-29-2023 12:31 PM
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.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 08:36 AM
Hi @cwolfe01
Can you share Ui policy or client script you have configured and also some screenshot if possible..
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 08:38 AM
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:
-
UI Policy: Review the UI policy that controls the visibility and mandatory attribute of
asset_tags
andasset
. Make sure the conditions are correctly set to evaluate the value ofasset_is_not_listed
. The UI policy should set the attributes as follows:asset_tags
: Visible (true) and Mandatory (false) whenasset_is_not_listed
is checked.asset_tags
: Visible (true) and Mandatory (true) whenasset_is_not_listed
is unchecked.asset
: Visible (true) and Mandatory (true) whenasset_is_not_listed
is checked.asset
: Visible (true) and Mandatory (false) whenasset_is_not_listed
is unchecked.
-
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 11:35 AM
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:
My second UI policy is shown below:
No other UI policies take any action against asset_tags, asset_is_not_listed, or asset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 12:00 PM
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.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates