0 votes
862 views
in Interview Questions by (30.6k points)

1 Answer

0 votes
by (30.6k points)

"Custom Ajax calls" from a coach means calling the server without leaving the page. In BPM / BAW you have these methods, each with its own error handling:

  1. Ajax service of a coach view (a service flow bound to a configuration option of type Service) - the built-in mechanism; the view calls it with this.context.options.myService(callbacks):
// custom coach view: option "lookupService" (Service) - input/output objects
var _this = this;
this.context.options.lookupService({
  params: { customerId: id },
  load:  function (data)  { _this.context.binding.set("value", data.customer); },
  error: function (err)   { _this.context.element.querySelector(".msg").textContent = "Lookup failed: " + (err.errorMessage || err); }
});
  1. UI Toolkit Service Call / Data controls - no code for the call; the On error event receives {errorCode, errorText, serviceInError}, On result the output; a busy indicator is built in.
  2. Direct REST calls with XMLHttpRequest / fetch to the BPM REST API (task, process, search) or to any API reachable from the browser: handle HTTP status codes yourself (401/403 = session or role, 500 = BPM error with Data.errorMessage), send BPMCSRFToken on BAW 20+ / CP4BA, and mind CORS for foreign hosts.
  3. Service flow called from the CSHS diagram (not strictly Ajax but the same effect with Stay on page boundary events): errors are error events on the step (question 2887).

Error handling that works in every method: fail fast on the server (service flow ends in an Error end event with a typed error object), map to a user message in one place (a coach view or a client-side script that reads tw.local.err), never swallow silently (write to the console and to an audit service), and time out (Service Call control option / xhr.timeout) so that a hanging back end does not freeze the coach.

References

Related questions

0 votes
2 answers 6.9k views
+1 vote
2 answers 7.5k views
+1 vote
2 answers 6.6k views
0 votes
1 answer 1.9k views
0 votes
1 answer 1.8k views
0 votes
1 answer 1.8k views
0 votes
1 answer 1.4k views
+1 vote
1 answer 2.3k 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
...