Welcome to the Alfresco Builder Network

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';

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: '[email protected]',
  companyemail: '[email protected]',
  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: '[email protected]'},
  {name: 'companyemail', value: '[email protected]'},
  {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);
});

Interested in trying Alfresco?

Try Now