0 votes
1.5k views
in Coach Views by (140 points)

1 Answer

0 votes
by (30.6k points)

A coach view does not own its data; it gets a binding from the coach. Initialise in this order, whichever fits the case:

  1. Default value of the variable - in the CSHS, select tw.local.myVar and tick Has default (business objects get all their fields initialised; lists start empty). The view sees the value at load time.
  2. Script before the coach - a client-side script task in the CSHS flow: tw.local.order = { status: "NEW", lines: [] }.
  3. Inside the coach view when the binding is empty - in the view's load handler:
// coach view load event
var b = this.context.binding;
if (b && (b.get("value") === undefined || b.get("value") === null || b.get("value") === "")) {
  b.set("value", this.context.options.defaultValue ? this.context.options.defaultValue.get("value") : "N/A");
}
// a complex binding: create the fields the view expects
var v = b.get("value");
if (v && v.status === undefined) b.set("value.status", "NEW");

Rules that avoid surprises: never assign this.context.binding = ... (only set("value", ...) writes through to the coach data); for lists use b.get("value").add(item) or set("value", []); if the view must work unbound, guard every access with if (this.context.binding). Configuration options are the right place for defaults that differ per coach (defaultValue above) - the CSHS can bind them to variables or literals.

References

Related questions

0 votes
1 answer 1.6k views
+1 vote
1 answer 1.2k views
0 votes
1 answer 725 views
0 votes
1 answer 1.2k views
0 votes
1 answer 1.2k views
0 votes
1 answer 1.4k views
0 votes
1 answer 1.0k views
0 votes
1 answer 1.1k views
0 votes
2 answers 3.1k views
asked Oct 16, 2017 in Coach Views by qaziMateen (120 points)
0 votes
1 answer 2.1k views
0 votes
1 answer 936 views
0 votes
1 answer 1.9k views
0 votes
1 answer 8.9k views
0 votes
1 answer 2.5k 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
...