ADF - get tasks-instances order By Id

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

ADF - get tasks-instances order By Id

Hi,

This is what i have done :

getActiveTasks (user): Promise<{}> {
  const listScriptPath = 'api/task-instances?authority=' + user +
    '&properties=wfvd_nomService,bpm_priority,bpm_status,bpm_dueDate,bpm_description&exclude=wcmwf:*&skipCount=0&maxItems=1000&';
  return this.apiService.getInstance().webScript
    .executeWebScript('GET', listScriptPath, this.scriptArgs, this.contextRoot, this.servicePath);
}

And this is what I get :


Is it possible to sort the results by id ?
I think i can use "orderBy" with "DESC" option in listScriptPath variable
but i don't find the correct syntax

thank you in advance
13 Replies
Highlighted
Alfresco Employee

Re: ADF - get tasks-instances order By Id

Is this a custom endpoint? Why do you fetch tasks via the webscript and not via the proper REST api?

Highlighted
Established Member II

Re: ADF - get tasks-instances order By Id

Because I have reproduced the project Share version that uses this way...

Highlighted
Established Member II

Re: ADF - get tasks-instances order By Id

So this what I try :

alfrescoJsApi = require('alfresco-js-api');
....

getActiveTasks (user): Promise<{}> {
const requestTasks  = new this.alfrescoJsApi.activiti.TaskQueryRequestRepresentation();
return this.apiService.getInstance().activiti.taskApi.listTasks(requestTasks);

}

and I get the following error :

error TS2304: Cannot find name 'require'.

Is-it the rirght way to retrieve asks user and if it is, how can i solve this error ?

Thank you

Highlighted
Alfresco Employee

Re: ADF - get tasks-instances order By Id

That example is for the node.js. Are you trying to use it with the node or with the Angular?

Highlighted
Established Member II

Re: ADF - get tasks-instances order By Id

Angular

Highlighted
Alfresco Employee

Re: ADF - get tasks-instances order By Id

Highlighted
Established Member II

Re: ADF - get tasks-instances order By Id

Thank you,

i have found a service:

this.apiService.getInstance().activiti.taskApi.listTasks(requestTasks);

requestTasks variable mut be TaskQueryRequestRepresentation type.

I have found this link that explain how to declare this type : adf-examples/ADF_2.0.0/javascript-api/angular2 at master · Alfresco/adf-examples · GitHub 

(.7  Call Process API)

 

const requestTasks = new this.alf.activiti.TaskQueryRequestRepresentation();


So i try to define it like this :

How to define requestTasks ?

Highlighted
Alfresco Employee

Re: ADF - get tasks-instances order By Id

This is JavaScript and everything is dynamic Smiley Happy You can create an object with JSON notation and cast it to any type if needed. The definition for IDE auto-completion is here: alfresco-js-api/index.d.ts at development · Alfresco/alfresco-js-api · GitHub 

So you can create an object like:

const request: any = {
  processInstanceId: 'value',
  text: 'value',
  otherProp: 'value'
}
Highlighted
Established Member II

Re: ADF - get tasks-instances order By Id

Thank you, it's difficult for me to understand all the mechanism....

I get another problem when executing the instruction in my getActiveTasks method :

const requestTasks: any = {
  processInstanceId: 'value',
  text: 'value',
  otherProp: 'value'
};

// const requestTasks = this.apiService.getInstance().activiti.TaskRepresentation;
return this.apiService.getInstance().activiti.taskApi.listTasks(requestTasks);

==> "ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'basicAuth' of null
TypeError: Cannot read property 'basicAuth' of null
at eval (alfresco-js-api.js:646)
at Array.forEach (<anonymous>)"

This is how my app works step by step :

And this the login html :

<adf-login
  [backgroundImageUrl]="'./assets/images/loginbg.png'"
  [logoImageUrl]="'./assets/images/klinck.png'"
  providers="ECM"
  [showLoginActions]="false"
  [showRememberMe]="false"
  (success)="loadData($event)">
</adf-login>

Thank you for your help