0 votes
1.2k views
in Client-Side Human Services by

1 Answer

0 votes
ago by (30.6k points)

The visibility rule of a control is evaluated against the coach's data at load and whenever the bound value changes; three reasons it "does not work" for a business object attribute, with the fix for each:

  1. The attribute is not initialised - tw.local.order.approved is undefined when order has no default; a rule approved == false is then false. Give the variable a default (Has default) or initialise it in a script before the coach.
  2. The rule references a different path than the control is bound to - visibility rules in the UI Toolkit are formulas that reference controls (${Approved}.getData()), not variables; the old (8.5.0) visibility "business data" rules compared a variable path. If the attribute is not bound to any control on the coach, put it into a hidden control (a Boolean bound to tw.local.order.approved) and reference that control.
  3. The change happens in code without the framework noticing - changing tw.local.order.approved = true in a client-side script on the same coach after load does not fire change events unless you go through the binding API or a control (${Approved}.setData(true)).
// UI Toolkit: Section "ApprovalDetails" > Visibility (formula, script mode)
${Approved}.getData() === true ? "EDITABLE" : "NONE"       // values: EDITABLE, READONLY, NONE (hidden), or true/false on older toolkits

// setting the value so the rule re-evaluates
${Approved}.setData(true);                                  // control API -> change event -> visibility updates
// or the binding API from a custom view:  this.context.binding.set("value.approved", true)

For the developerWorks scenario you linked (a view bound to a list element's attribute): inside a repeated view, reference relative controls (${../Approved}) and make sure the list element itself is initialised for every row. Debug by putting the same expression into an Output Text's formula - you see what the rule sees.

References

Related questions

0 votes
1 answer 2.9k views
+1 vote
1 answer 2.5k views
+1 vote
1 answer 1.2k views
0 votes
1 answer 1.4k views
0 votes
1 answer 2.1k views
0 votes
1 answer 1.3k views
0 votes
1 answer 2.3k views
0 votes
1 answer 1.7k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...