Maurizio Vitale cd7e21a23d [ADF-4858] Make sure process-services works with ng commands (#5067)
* Process-services:
Making sure you can run
ng build process-services
ng test process-services

* Fix the path of the styles

* move the file in the right place
2019-09-20 09:47:17 +01:00

11 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Process Service v2.0.0 Active 2019-03-20

Process Service

Manages process instances, process variables, and process audit Log.

Class members

Methods

Details

Parameter and return value classes are defined in the Alfresco JS API. See the Activiti REST API pages for further information.

Importing

import { ProcessService, ProcessInstance, ProcessInstanceVariable, 
         ProcessDefinitionRepresentation, ProcessFilterParamRepresentationModel, TaskDetailsModel } from '@alfresco/adf-process-services';

export class SomePageComponent implements OnInit {

  constructor(private processService: ProcessService) {
  }

Example of starting a process

When starting a process, you can choose to pass in form field values or process variables but not both in the same call.

In this example, values are supplied to the start form that has been defined for the process:

const processDefinitionId = 'InvoiceApprovalProcess:2:21';
const name = 'Sample Invoice Process';
const outcome = null;
const startFormValues = {
  approver: 'admin@app.activiti.com',
  companyemail: 'someone@acme.com',
  invoicetobeapproved: null
};
this.processService.startProcess(processDefinitionId, name, outcome, startFormValues)
  .subscribe( (processInstance: ProcessInstance) => {
  console.log('ProcessInstance: ', processInstance);
}, error => {
  console.log('Error: ', error);
});

A ProcessInstance object is returned for a successfully started process. This implements the ProcessInstanceRepresentation interface.

You can start the process with process variables instead of form field values using code like the following:

const processDefinitionId = 'InvoiceApprovalProcess:2:21';
const name = 'Sample Invoice Process (Var)';
const variables: ProcessInstanceVariable[] = [
  {name: 'approver', value: 'admin@app.activiti.com'},
  {name: 'companyemail', value: 'someone@acme.com'},
  {name: 'invoicetobeapproved', value: null},
  {name: 'sampleVar', value: 'hello'}
];
this.processService.startProcess(processDefinitionId, name, null, null, variables)
  .subscribe( (processInstance: ProcessInstance) => {
  console.log('ProcessInstance: ', processInstance);
}, error => {
  console.log('Error: ', error);
});

You can also start a process that has no start form and no process variables:

const processDefinitionId = 'SimpleProcess:1:2';
const name = 'Sample Process';
this.processService.startProcess(processDefinitionId, name)
  .subscribe( (processInstance: ProcessInstance) => {
  console.log('ProcessInstance: ', processInstance);
}, error => {
  console.log('Error: ', error);
});