The CreatorCon Call for Content is officially open! Get started here.

What is the best way to prevent a "task" UI policy from running on /one/ task-child table?

Tim Woodruff
Mega Guru

scenario:

  You have a UI policy on the base task table

  You want "Reverse if false" to be true.

  You want it to apply to all task sub-tables (incident, problem, change, etc.), EXCEPT for one (incident).

How can you make this policy run on all sub-task tables EXCEPT incident?

You could simply add a condition "Task type is not incident", but then the condition would always evaluate to false, which means that the "reverse if false" condition would trigger. The UI policy would apply, but would have the opposite effect from what's listed in the UI policy actions, resulting in strange behavior. In fact, I have only been able to come up with two ways to accomplish this, and they're both ugly and high-maintenance:

Option 1: Disable "reverse is false" Create an identical-but-opposite UI policy with the exact opposite condition, and UI policy actions with exact opposite settings. For example, if your UI policy runs when "active is true", this new policy should run when "active is false". If a UI policy action on the original UI policy sets "mandatory" to "true", then the new policy should have an action that sets "mandatory" to "false" on the same field.

Then, if you add the additional condition to both the original and new UI policy that says "task type is not incident", since neither of them has the "Reverse if false" field set to true, this will effectively leave the incident table alone, as far as this one UI policy is concerned.

The down-side to this, is that now you have two sets of policies to maintain, and they must match exactly.

Option 2: Remove all of the UI policy actions from the original UI policy, and (in the Advanced view, under the Script section), check Run scripts.

You can use the first thing the script does, both when the condition is true and when it's false, to check if the table is incident:

if (current.sys_class_name == 'incident') {

  return;

}

//Put UI policy action code here...

This still has the problem where you have to separately maintain the "if true" and "if false" actions, but at least they're stored within the same UI policy record now.

Does anyone have any advice on how the above scenario can be accomplished without resorting to these methods? I did notice there's a "sys_overrides" field on the UI policy table, but I believe that's for domain separation only, and I couldn't get it to do anything for me in this situation.

5 REPLIES 5

Michael Fry1
Kilo Patron

Can't you just use a condition under When to run: Task type - is not - incident.


Can't you just use a condition under When to run: Task type - is not - incident.


Well I could, but as I mentioned on line 7, that would make the condition always evaluate to "false" on the incident table. This means that the "reverse if false" action would happen, so if I had a field become visible in the UI actions, it would become non-visible on the incident table.


Yeah - mine has Reverse unchecked. Tough choices are right.


I guess script out both your execute if true and execute if false script sections such that you disqualify tables on the "execute if false" script.     Its not the same as exploiting "reverse if false", but at least its workable (I think).



You've probably done so already, but this is one area I'd be extremely certain the *TASK* based functionality is (1) absolutely universally true and (2) worth the tech debt.