Title | Added | Status | Last reviewed |
---|---|---|---|
Process Service |
v2.0.0 |
Active |
2019-03-20 |
Manages process instances, process variables, and process audit Log.
- cancelProcess(processInstanceId:
string
):Observable
<void>
Cancels a process instance.- processInstanceId:
string
- ID of process to cancel - Returns
Observable
<void>
- Null response notifying when the operation is complete
- processInstanceId:
- createOrUpdateProcessInstanceVariables(processInstanceId:
string
, variables:RestVariable
[]
):Observable
<
ProcessInstanceVariable
[]>
Creates or updates variables for a process instance.- processInstanceId:
string
- ID of the target process - variables:
RestVariable
[]
- Variables to update - Returns
Observable
<
ProcessInstanceVariable
[]>
- Array of instance variable info
- processInstanceId:
- deleteProcessInstanceVariable(processInstanceId:
string
, variableName:string
):Observable
<void>
Deletes a variable for a process instance.- processInstanceId:
string
- ID of the target process - variableName:
string
- Name of the variable to delete - Returns
Observable
<void>
- Null response notifying when the operation is complete
- processInstanceId:
- fetchProcessAuditJsonById(processId:
string
):Observable
<any>
Fetches the Process Audit information in a JSON format.- processId:
string
- ID of the target process - Returns
Observable
<any>
- JSON data
- processId:
- fetchProcessAuditPdfById(processId:
string
):Observable
<
Blob
>
Fetches the Process Audit information as a PDF.- processId:
string
- ID of the target process - Returns
Observable
<
Blob
>
- Binary PDF data
- processId:
- getProcess(processInstanceId:
string
):Observable
<
ProcessInstance
>
Gets Process Instance metadata.- processInstanceId:
string
- ID of the target process - Returns
Observable
<
ProcessInstance
>
- Metadata for the instance
- processInstanceId:
- getProcessDefinitions(appId?:
number
):Observable
<
ProcessDefinitionRepresentation
[]>
Gets process definitions associated with an app.- appId:
number
- (Optional) ID of a target app - Returns
Observable
<
ProcessDefinitionRepresentation
[]>
- Array of process definitions
- appId:
- getProcessInstanceVariables(processInstanceId:
string
):Observable
<
ProcessInstanceVariable
[]>
Gets the variables for a process instance.- processInstanceId:
string
- ID of the target process - Returns
Observable
<
ProcessInstanceVariable
[]>
- Array of instance variable info
- processInstanceId:
- getProcessInstances(requestNode:
ProcessFilterParamRepresentationModel
, processDefinitionKey?:string
):Observable
<
ProcessListModel
>
Gets process instances for a filter and optionally a process definition.- requestNode:
ProcessFilterParamRepresentationModel
- Filter for instances - processDefinitionKey:
string
- (Optional) Limits returned instances to a process definition - Returns
Observable
<
ProcessListModel
>
- List of process instances
- requestNode:
- getProcessTasks(processInstanceId:
string
, state?:string
):Observable
<
TaskDetailsModel
[]>
Gets task instances for a process instance.- processInstanceId:
string
- ID of the process instance - state:
string
- (Optional) Task state filter (can be "active" or "completed") - Returns
Observable
<
TaskDetailsModel
[]>
- Array of task instance details
- processInstanceId:
- getProcesses(requestNode:
ProcessFilterParamRepresentationModel
, processDefinitionKey?:string
):Observable
<
ProcessListModel
>
Gets processes for a filter and optionally a process definition.- requestNode:
ProcessFilterParamRepresentationModel
- Filter for instances - processDefinitionKey:
string
- (Optional) Limits returned instances to a process definition - Returns
Observable
<
ProcessListModel
>
- List of processes
- requestNode:
- startProcess(processDefinitionId:
string
, name:string
, outcome?:string
, startFormValues?:FormValues
, variables?:ProcessInstanceVariable
[]
):Observable
<
ProcessInstance
>
Starts a process based on a process definition, name, form values or variables.- processDefinitionId:
string
- Process definition ID - name:
string
- Process name - outcome:
string
- (Optional) Process outcome - startFormValues:
FormValues
- (Optional) Values for the start form - variables:
ProcessInstanceVariable
[]
- (Optional) Array of process instance variables - Returns
Observable
<
ProcessInstance
>
- Details of the process instance just started
- processDefinitionId:
Parameter and return value classes are defined in the Alfresco JS API. See the Activiti REST API pages for further information.
import { ProcessService, ProcessInstance, ProcessInstanceVariable,
ProcessDefinitionRepresentation, ProcessFilterParamRepresentationModel, TaskDetailsModel } from '@alfresco/adf-process-services';
export class SomePageComponent implements OnInit {
constructor(private processService: ProcessService) {
}
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);
});