What is the best way to prevent a "task" UI policy from running on /one/ task-child table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2016 02:02 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2017 09:18 AM
I'm confused by your option 2. How are you shifting the advanced scripts to run server-side rather than client? (to access current)
If this were me, I'd drop the UI policy entirely and use a client script. You lose order this way, but I usually find that if I'm relying on order, then I'm probably better off combining those conflicting policies anyway.