Exposing a Client Side Human Service via a URL

This is a quick one. I have a couple of longer ones that are 80% complete but in the meantime here’s some information that I needed recently and couldn’t find anywhere on the Internet…
If (in IBM BPM 8.5.7) you have a Client Side Human Service (CSHS) that you want to expose via a URL *and* you are generating the URLs in another CSHS then you will need some environment-specific logic to get things working on both Process Centres and Process Servers (using the correct version of your CSHS).
Here's some JavaScript…
var markup = "";
if (this.context.bpm.system.context.callerModelBranchId != null && this.context.bpm.system.context.callerModelBranchId.length > 0) {
markup = "<a href='/teamworks/executecf?modelID=?&branchID=" + this.context.bpm.system.context.callerModelBranchId + "&tw.local.processInstanceId=" + this.context.options.instanceId.get("value") + "' target=_blank>" + "Process Centre Link" + "</a>";
}
else if (this.context.bpm.system.context.callerModelSnapshotId != null && this.context.bpm.system.context.callerModelSnapshotId.length > 0) {
markup = "<a href='/teamworks/executecf?modelID=?&snapshotID=" + this.context.bpm.system.context.callerModelSnapshotId + "&tw.local.processInstanceId=" + this.context.options.instanceId.get("value") + "' target=_blank>" + "Process Server Link" + "</a>";
}
else {
console.error(“A meaningful error that indicates that you cannot create a link...");
}
this.context.element.getElementsByClassName(“myClassName")[0].innerHTML = markup;
view raw url hosted with ❤ by GitHub

Some supporting comments…
  • The main piece of information here (that I couldn’t find anywhere else) is that you need Branch ID on a Process Centre and Snapshot ID on a Process Server. On a Process Centre it will (as far as I can tell) always use the Tip (latest version) of the specified Branch (but it always needs the Branch, even if you only have one active one). On a Process Server there isn’t really a concept of Branches (only Snapshots), so it needs the Snapshot identifier.
  • My exposed CSHS has an input parameter called processInstanceId and I’m getting the value from the Coach View configuration that this script is in.
That’s it. Told you it was a quick one. There is a nice REST API that you can use on a given server to get the details of exposed Services (including URLs)…