On Catalog UI Policy - what happen when 'Reverse if false' is true and the action 'Clear the variable name' is false?

valter479
Tera Contributor

On Catalog UI Policy - what happen when 'Reverse if false' is true and the action 'Clear the variable name' is false?

Does that mean if the condition of the UI policy is false then the value of the variable with be clear?

The behavior I am seeing is the value does not get clear.

 

 

 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Checking "Clear the variable value" checkbox is to activate a process to clear field value. When it's unchecked, the process is inactivated.

The checkbox is like adding the following script in "Execute if true" condition.

function onCondition() {
  g_form.clearValue('field1');  // field name to clear
}

Other UI Policy conditions such as "Mandatory", "Visible", "Read only" have opposites but there's no opposite process to "Clear the variable value" because the script would not know what to populate the field with. In other words, "Mandatory", "Visible", "Read only"  are always activated but "Clear the variable value" would only become activated when it is checked. That's probably why "Clear the variable value" is a checkbox like "Activate" checkboxes in other pages.

As such, checking it will activate it and unchecking will inactivate clearing the field. When it is inactivated, nothing will be done whether the condition is satisfied or unsatisfied.

Going back to the original question, if ""Clear the variable value" is unchecked, nothing will happen regardless of whether "Reverse if false" is true or false.

View solution in original post

7 REPLIES 7

Allen Andreas
Administrator
Administrator

Hi,

It is only going to execute when the condition of the UI Policy is true and when true, it'll clear the field value if "clear the field/variable value" is also true.

So in other words, the "clear the field/variable value" checkbox is normally used when you use opposite conditions (so instead of you making the UI Policy when you want it to happen for true (i.e., Configuration Item is 'x') -- you set it to execute for the opposite (Configuration Item is not 'x'). Then the UI Policy action for field 'y' executes and has it's value cleared (if you set that checkbox to true). It would then execute the other settings such as mandatory = false...meaning the reverse happens where mandatory = true, otherwise.

It takes a short bit to think through, but once you get it, you'll see what I'm talking about.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I'm glad you found a correct answer.

I tried to state that above in my reply (which stated that the condition needed to be true and only then would the clear variable/field value field execute if also set to true), as well as gave suggestion towards creating the opposite condition for the clear variable/field value to be used correctly when it makes the most sense (to the SN settings), but perhaps it didn't come across clearly.

My apologies for that.

Take care!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

shloke04
Kilo Patron

Hi,

Reverse if false means that if the condition in the UI Policy doesn't meet the UI policy actions defined will reverse what they do on meeting the condition.

i.e. if a UI policy action is making a field mandatory on some condition. If the condition is not meet it the UI policy will make the field non mandatory.

Tried replicating your scenario in my PDI as well and below are the observations noted:

Now for your scenario, it should be like below settings:

1) Reverse if False should be marked as True

2) Clear Variable checkbox should also be marked as True for the variable which you want to clear out.

This works well in my PDI. Can you share your screenshot on how you have configured it right now to assist you further.

Also there is a good post on clear variable , please refer the same as well:

https://pathwayscg.com/using-the-clear-the-variable-value-field/

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Here's an article which I wrote a while back which covers Clear the field value / Clear the variable value.

2019-07-16 Clear the field value / Clear the variable value

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn