0 votes
900 views
in Coach Views by (21.5k points)

1 Answer

0 votes
by (30.6k points)

"Page load" scripts in BPM 8.x are coach view load handlers - the coach itself has no script slot, but any coach view placed on it runs its load when the page renders. Options from simplest to most controlled:

  1. A "Page Script" coach view: an empty custom coach view (no layout) with the code in its load event; drop it on every coach where it is needed, pass parameters as configuration options. Runs once per page load, after the DOM of the coach exists.
  2. The coach's own controls: the UI Toolkit controls have an On load event - put the page-level script on the top-level Vertical Layout's On load (it fires when the layout is ready); on older toolkits use a hidden control.
  3. Coach view load vs view: load fires once when the view is created, view (8.5.7+) every time it becomes visible - use view for scripts that must re-run when returning to a coach in a wizard.
// Page Script coach view - load handler
var _this = this;
// wait for the toolkit controls to be ready (they load in the same pass; use a tick to be safe)
setTimeout(function () {
  var e = bpmext.ui.getView("Email");                                    // BPM UI Toolkit helper: find a control by id from anywhere on the page
  if (e && !e.getData()) e.setData(_this.context.options.defaultEmail.get("value"));
  document.title = "Order " + (bpmext.ui.getView("OrderNumber") || {}).getData();
}, 0);

Heritage coaches (7.5-style) had a Custom HTML block where a <script> ran at load - the coach view load handler is its replacement. Avoid window.onload: the coach is rendered after the window has loaded, so it never fires for your script.

References

Related questions

0 votes
1 answer 774 views
0 votes
1 answer 1.7k views
0 votes
1 answer 2.0k views
0 votes
1 answer 3.0k views
0 votes
1 answer 1.7k views
0 votes
1 answer 1.9k views
0 votes
1 answer 2.1k views
asked Aug 22, 2023 by sanjay_hdi (360 points)
0 votes
1 answer 1.3k views
0 votes
1 answer 1.2k views
0 votes
1 answer 668 views
0 votes
1 answer 1.1k 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
...