0 votes
3.4k views
in Portal by (270 points)
edited by
The below code refreshes the page.

var taskUrl = "/ProcessPortal/launchTaskCompletion?taskId="+taskId;

window.open(taskUrl,"_self");

Need something which works similar to directly claiming a task from Process portal.

Kindly suggest!

1 Answer

0 votes
ago by (30.6k points)

launchTaskCompletion is a portal URL, so it always loads the portal task page. To claim a task without leaving your startable (dashboard) UI, call the task REST API from the coach and then open or refresh only the part you want.

Claim with the Process REST API (classic resource, works on every BPM 8.5 / BAW version):

// client-side script in the coach (BPM UI Toolkit / plain XMLHttpRequest)
function claimTask(taskId, done) {
  var xhr = new XMLHttpRequest();
  xhr.open("PUT", "/rest/bpm/wle/v1/task/" + taskId + "?action=assign&toMe=true&parts=none", true);
  xhr.setRequestHeader("Accept", "application/json");
  xhr.onreadystatechange = function () {
    if (xhr.readyState !== 4) return;
    if (xhr.status === 200) done(null, JSON.parse(xhr.responseText));
    else done(JSON.parse(xhr.responseText).Data.errorMessage);
  };
  xhr.send();
}
claimTask("1234", function (err) { if (err) alert(err); else /* the task is now mine */ openTask("1234"); });

On BAW 21 and later the same is POST /bpm/user-tasks/{id}/claim (Process REST v2). Both need the BPMCSRFToken header on the CP4BA / newer traditional servers - obtain it once with POST /rest/bpm/wle/v1/system/login (or /bpm/system/login) and send it with every call.

Then show the task without a full reload:

  • In a dashboard built as a CSHS: call the task's human service in a UI Toolkit Modal Section or an IFrame-style control with the task page URL /teamworks/process.lsw?zWorkflowState=1&zTaskId=1234 (the coach renders inside the frame, the dashboard stays).
  • Use the Process Portal task list's own behaviour: window.open("/ProcessPortal/launchTaskCompletion?taskId=1234", "_blank") opens a new tab; the dashboard is untouched.
  • For a completely custom UI, the "Task Completion" flow of the Process Portal REST API (/rest/bpm/wle/v1/task/{id}?action=finish, ?action=setData) lets you complete the task without any portal page at all.

References

Related questions

0 votes
2 answers 10.2k views
0 votes
1 answer 1.8k views
0 votes
1 answer 8.9k views
0 votes
1 answer 3.2k 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
...