- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2022 02:18 AM
UI policy "Clear the variable value" makes a field empty even the condition is false in Catalog items.
I've created a catalog item with several variables, then added UI policy to show and require some variables based on answer to a previous question.
- "Applies on Requested Items" is checked on UI Policy
- UI Policy Action is configured as follows:
It works fine in service portal, but then on requested item view the value is empty (it should include user's answer).
It works if I uncheck the 'Clear the variable value', but I want it to be cleared when user selects something else... Is there any other way to make it work?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 01:29 PM
for some weird reason UI policies were impacting when onload is checked so UI policy script was added to fix it where clear variable value is required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2022 03:52 AM
Hope that 'UI Type' field on UI Policy is 'ALL".
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2022 04:13 AM
I don't see such kind of field on the ui policy but in the xml its value is set to 0.
My ui policy applies to
I think UI type field is visible only when run script is selected where you select the desktop or all option.
this is related to UI Policy action where the value is set to true for clear value and the user input is not visible on the backend.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2022 04:18 AM
Hi @Noor Mohammad1 ,
you can check Applies on Requested Items on UI policy form. If still not working try below.
You can use the onchange catalog client on you are variable and UI type should be All and use below script.
If it is not helpful share the exact conditions I will help you.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue != '') { //you can give value and clear based on the value
g_form.clearValue('variablename'); //add your variable that need to clear
}
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 07:24 AM
Hi @Noor Mohammad1 ,
If your issue got resolved close the question by Accepting solution and hit thumb icon.
If not reply and share the details.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar