Eugenio Romano c3452a4f62
Documentation build (#6762)
* move doc dependency in doctools

* add ignore link

* rebuild doc

* version index

* put it back some deps
2021-03-03 14:08:15 +00: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);
});