Redirect to task details on click of app

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
anitapatil_bld
Active Member II

Redirect to task details on click of app

I have process with 2 tasks namely t1 and t2.
I have a case to start a process on clicking the app and redirect it to task details page.
For this I have written code to start the process on click of app now it is started and i want to redirect it to
t1 task details page
in app.view.component.html
```
<adf-apps (appClick)="onAppClickStartProcess($event)"></adf-apps>
```

in app.view.component.ts
```
onAppClickStartProcess(app: AppDefinitionRepresentationModel) {
this.apppid1 = app.id;
this.processService.getProcessDefinitions(this.apppid1).subscribe(
data => {
console.dir(data)
this.apppid = data;
this.exdepId = this.apppid[0].id;

this.processService.startProcess(this.exdepId, "aaa", "", "", [])

.subscribe(
data => {
//at precent redirecting to this route
this.router.navigate(['activiti/apps', app.id || 0, 'tasks']);
//but it should redirect to this route
//this.router.navigate(['activiti/apps', app.id || 0, 'tasks', taskid]);

});

});
}
```

Kindly help me out. 

Thanks & Regards

Anita Patil

6 Replies
cjose
Senior Member II

Re: Redirect to task details on click of app

You will need to do a task query inside "this.processService.startProcess().subscribe()" using the process instance id returned by startProcess(). The task query response will include the task id which you can then use to re-direct to "this.router.navigate(['activiti/apps', app.id || 0, 'tasks', taskid]);"

Hope this helps!

Ciju

anitapatil_bld
Active Member II

Re: Redirect to task details on click of app

Thank you Ciju Joseph It worked for me. I am able to get taskid and redirect to task details page. As you said added the code inside "this.processService.startProcess().subscribe()".

Code: 

onAppClickStartProcess(app: AppDefinitionRepresentationModel) {
this.apppid1 = app.id;
console.log("apppid==" + this.apppid);
this.processService.getProcessDefinitions(this.apppid1).subscribe(
data => {
this.apppid = data;
this.exdepId = this.apppid[0].id;
this.processService.startProcess(this.exdepId, "aaa", "", "")
.subscribe((processInstance: ProcessInstance) => {
this.processService.getProcessTasks(processInstance.id, "all").subscribe(
data => {
this.router.navigate(['app-list/apps', app.id || 0, 'tasks', data[0].id]);
}
);

}, error => {
console.log('Error: ', error);
});

});
}
 
cjose
Senior Member II

Re: Redirect to task details on click of app

Great, thanks for posting the working code back Smiley Happy

anitapatil_bld
Active Member II

Re: Redirect to task details on click of app

Hi,

I want to do little modification in it before starting the process I should check whether the particular app i clicked which got any task are in running mode. If yes I should redirect to that task details page else I should call the start process logic. To do this I want process instance id of particular app. How can I achieve this case? any idea?

cjose
Senior Member II

Re: Redirect to task details on click of app

query for tasks using app id as the filter - Task List | Alfresco Documentation !

anitapatil_bld
Active Member II

Re: Redirect to task details on click of app

Hi,

 I have checked with task query api it is actually a post api, Is there any get api available for task list?

Regards

Anita Patil