alfresco-ng2-components/docs/process-services/start-process.component.md
Marouan Bentaleb 5a6d8d8a2a [ADF-3331] Automated tests for Viewer Component (#3615)
* Automation tests for Viewer Component - Content Services

* Deleting alfresco-ng2-components.iml

* Updating Viewer Page for failing tests

* Adding tests for Viewer Component and some minor changes on Viewer Component - Content Services

* Removing some lines used to test

* Automation tests for Viewer component and Viewer component - Integration with Router + minor changes on tests for Viewer Component - Content Services

* Correcting an import + some improvement to the code

* Correcting tests for opening different file extensions

* Removing a console.log I forgot

* Refactoring the test in Viewer Component

* Refacotring using lint

* Adding browser refresh after each file type

* Moving tests to proper folder

* Minor changes

* remove faulty BE files from e2e

* fix test viewer

* fix process service tests

* fix test

* fix process test

* fix lint
timeout decrease

* increase some timeouts to fix CS e2e

* lint fix
2018-09-25 21:58:22 +01:00

5.7 KiB

Added, Status, Last reviewed
Added Status Last reviewed
v2.0.0 Active 2018-03-13

Start Process component

Starts a process.

adf-start-process

Contents

Basic Usage

<adf-start-process 
   [appId]="YOUR_APP_ID">
</adf-start-process>

Class members

Properties

Name Type Description
appId number (optional): Limit the list of processes which can be started to those contained in the specified app
name string (optional) name to assign to the current process
processDefinitionName string (optional) definition name of the process to start
processFilterSelector boolean (optional) Enables automatic selection of process when typing dowm in process field, true by default
variables ProcessInstanceVariable[] Variables in input to the process RestVariable
values FormValues Parameter to pass form field values in the start form if is associated
showSelectProcessDropdown boolean hide or show the process selection drodown, true by default

Events

Name Type Description
start EventEmitter<ProcessInstance> Emitted when the process starts
cancel EventEmitter<ProcessInstance> Emitted when the process is canceled
error EventEmitter<ProcessInstance> Emitted when the start process operation fails

Details

Starting a process with a default name and pre-selected process definition name

 <adf-start-process 
      [appId]="YOUR_APP_ID"
      [name]="PROCESS_NAME"
      [processDefinitionName]="PROCESS_DEFINITION_NAME">
 </adf-start-process>		 

You can use the processDefinitionName property to select which process will be selected by default on the dropdown (when there is more than one process to choose from). Use the name property to set the name shown on the dropdown item.

Starting a process not included in an app

 <adf-start-process 
      [processDefinitionName]="PROCESS_DEFINITION_NAME">
 </adf-start-process>		 

Use processDefinitionName to set the dropdown item as in the example above.

Custom data example

The following example shows how to pass in form field values to initialize the start form for the process:

const formValues: FormValues  = {
    'test_1': 'value_1',
    'test_2': 'value_2',
    'test_3': 'value_1',
    'test_4': 'dropdown_id',
    'test_5': 'dropdown_label',
    'dropdown': {'id': 'dropdown_id', 'name': 'dropdown_label'}
};
<adf-start-process 
    [values]="formValues"
    [appId]="YOUR_APP_ID" >
</adf-start-process>

Attaching a File to the start form of the process

You can see a repository in the Alfresco Repositories list once it is created in APS. If the repository is set up with an ID value of anything other than 1 then you will need to declare it in app.config.json. For example, if the repository's ID is 1002 and its name is alfresco then you would set the alfrescoRepositoryName property inapp.config.json to alfresco-1002 as follows:

{
    application: {
        name: 'Alfresco ADF Application'
    },
    ecmHost: 'http://{hostname}{:port}/ecm',
    bpmHost: 'http://{hostname}{:port}/bpm',
    logLevel: 'silent',
    alfrescoRepositoryName : 'alfresco-1002'
}       

You then need to pass the node as the input values object with the other properties:

let node: MinimalNodeEntryEntity = null;

 this.nodesApiService.getNode(NODE_ID).subscribe((minimalNode) => this.node = minimalNode);

const formValues: FormValues  = {
    'file' : node
    'field_one': 'example text'
};

You could pass multiple nodes too:

const nodes: string[] = [NODE_ID_1, NODE_ID_2];

const values: FormValues = {
        'files': []
      };

      Observable.from(nodes)
        .flatMap((nodeId) => this.nodesApiService.getNode(nodeId))
        .subscribe(
              (node) => {
                values.files.push(node);
              },
              (error) => console.log(error) ,
              () => {
                this.formValues = values;
              });
    });

Note that in the object above, the key file is the name of the attach file field in the start form of the process. The value of the file property must be a MinimalNodeEntryEntity:

<adf-start-process 
    [values]="formValues"
    [appId]="YOUR_APP_ID" >
</adf-start-process>

The result will be the start form prefilled with the file data:

Start process load file

See also