Movatterモバイル変換


[0]ホーム

URL:


The latest Alfresco documentation has moved to the Hyland Documentation Portal. Click here for the latest versions:support.hyland.com.
In: process-automationIn: All docs
Close
Alfresco Process Automation

Scripts

Scripts are used to execute a script as part of a process. Process variables can be passed to the script and the results of a script can be sent back to a process instance as process variables. Any JavaScript that is created by the modeling application has the same permissions assigned to it as the logged in user. This is helpful because it allows the logged in user to test their own scripts with their own files.

Script design uses the functionality of theMonaco Editor and uses theGraalVM JavaScript Engine for execution.

Scripts are added to a process definition using ascript task.

Properties

The basic properties of a script are:

PropertyDescription
Script nameRequired. The name of the script. Must be in lowercase and between 1 and 26 characters in length. Alphanumeric characters and hyphens are allowed, however the name must begin with a letter and end alphanumerically, for exampleorder-script
LanguageRequired. The development language the script is written in, for exampleJavascript.
Script descriptionOptional. A description of what the script should be used for, for exampleReturns the prefixed order number.

Create a script

To create a script:

  1. Sign into the Modeling Application and open a project.

  2. Click theNEW dropdown.

  3. Select how to create the script:

    • Create > Script creates a new, empty script.

    • Upload > Script allows for uploading an existing script.bin file into the Modeling Application.

    Alternatively use the+ orUpload buttons next toScripts in the left-hand menu.

  4. Enter a name and optional description.

Script modeling

The Modeling Application contains two tabs for creating and managing scripts.

TheScript Editor is the GUI for modeling scripts by typing in the declared language. The editor has autocomplete functionality for APIs and script variables. TheMetadata contains the properties related to the script.

auto complete

Simulation

Once a script has been written, it can be simulated by entering potential inputs and viewing their output.

In the UI click theSimulate button after entering the input values to simulate. The results will be populated in the outputs section.

Variables

There are two types of variables associated with a script. Script variables are stored as JSON and are used to pass values between a process and a script. Declared variables are used within the script body itself.

Script variables

Script variables can be used to pass and receive values fromprocess variables.

The properties for a script variable are:

PropertyDescription
nameA unique name that can contain alphanumeric characters and underscores but must begin with a letter, for examplevar_3
typeA data type selected from a dropdown. See the following table for a list of data types, for exampleString
requiredSets whether the script variable must contain a value when the task is started, for examplefalse
valueAn optional default value for the script variable, for exampleice-cream

The data types that a script variable can be set as are:

TypeDescription
StringA sequence of characters, for example#Mint-Ice-Cream-4!
IntegerA positive whole number, for example642
BooleanA value of eithertrue orfalse
DateA specific date in the formatYYYY-MM-DD, for example2020-04-22
DatetimeA specific date and time in the formatYYYY-MM-DD HH:mm:ss, for example2020-09-10 22:30:00
FileAfile uploaded into a process definition or as part of a process instance or task
JSONA JSON object, for example{"flavor" : "caramel"}
FolderA folder object described as JSON, for example"name": "mint-folder"
ArrayA comma separated list of entries, for examplemint, strawberry, vanilla that will be formatted to["mint","strawberry","vanilla"]

Declared variables

Declared variables are used within the script itself and can be set to the value of a script variable by using the prefixvariables. to reference the script variable. An input variable will set a declared variable to the value of a script variable when the script is executed.

For example, in a process the script variablescost andorders will have their values set from process variables. The declared variablescostOfItem andnumberOfOrders can then be set to these values using the following:

let costOfItem = variables.cost;let numberOfOrders = variables.orders;

The value of the script variabletotalCost will then be set after the script has executed by using the following:

variables.totalCost = costOfItem * numberOfOrders;

The value of the script variabletotalCost can finally be sent back to the process bymapping it to a process variable.

Process scripts

Scripts can be used to start a process instance by building a payload.

For example, use the process definition ID and set the process variables using:

let startProcessInstanceCmd = processPayloadBuilder.start().withProcessDefinitionKey("Process_GyW7Ekkw").withVariable("orderNumber": variables.orderNumber).withVariable("quantity": variables.quantity).build();commandProducer.send(startProcessInstanceCmd);

Content APIs

The following content APIs are supported:

  • ActionService
  • GroupService
  • NodeService
  • PeopleService
  • QueryService
  • SearchService
  • SiteService
  • TagService

Note: The API scripts can be tested in the simulator on the scripts window.

You can create the object by accessing the API which then allows you to make use of all its methods.

For example:

const nodeBodyCreate = { name: variables.name, nodeType: "cm:folder" };const nodeService = new NodeService();nodeService.createNode(variables.parentNodeId, nodeBodyCreate);

Runtime APIs

The following APIs are supported:

  • ProcessInstanceAdminControllerImplApi
  • ProcessInstanceControllerImplApi
  • ProcessInstanceTasksControllerImplApi
  • ProcessInstanceVariableAdminControllerImplApi
  • ProcessInstanceVariableControllerImpl
  • TaskAdminControllerImplApi
  • TaskControllerImplApi
  • TaskVariableAdminControllerImplApi
  • TaskVariableControllerImplApi

Using the following names you can perform all the actions related to the APIs mentioned above:

  • RuntimeProcessInstanceAdminService: APA Runtime Process Instance Admin REST API (it includesProcessInstanceAdminControllerImplApi, andProcessInstanceVariableAdminControllerImplApi)
  • RuntimeProcessInstanceService: APA Runtime Process Instance REST API (it includesProcessInstanceControllerImplApi,ProcessInstanceTasksControllerImplApi, andProcessInstanceVariableControllerImpl)
  • RuntimeTaskAdminService: APA Runtime Task Admin API (it includesTaskControllerImplApi, andTaskVariableAdminControllerImplApi)
  • RuntimeTaskService: APA Runtime Task API (it includesTaskControllerImplApi, andTaskVariableControllerImplApi)

For example:

const startProcessPayload = { businessKey: variables.businessKey, payloadType: 'StartProcessPayload', processDefinitionKey: variables.processKey, variables: { fileArray: variables.fileArray } };const runtimeProcessInstanceService = new RuntimeProcessInstanceService();runtimeProcessInstanceService.startProcess(startProcessPayload);

Query APIs

The following APIs are currently supported:

  • ProcessInstanceAdminControllerApi
  • ProcessInstanceControllerApi
  • ProcessInstanceDeleteControllerApi
  • ProcessInstanceDiagramAdminControllerApi
  • ProcessInstanceDiagramControllerApi
  • ProcessInstanceServiceTasksAdminControllerApi
  • ProcessInstanceTasksControllerApi
  • ProcessInstanceVariableAdminControllerApi
  • ProcessInstanceVariableControllerApi
  • TaskAdminControllerApi
  • TaskControllerApi
  • TaskVariableAdminControllerApi
  • TaskVariableControllerApi

You can use the following names to perform all the actions related to the APIs indicated above:

  • QueryProcessInstanceAdminService: APA Query Process Instance Admin REST API (it includesProcessInstanceAdminControllerApi,ProcessInstanceDiagramAdminControllerApi,ProcessInstanceServiceTasksAdminControllerApi, andProcessInstanceVariableAdminControllerApi)
  • QueryProcessInstanceService: APA Query Process Instance REST API (it includesProcessInstanceControllerApi,ProcessInstanceDeleteControllerApi,ProcessInstanceDiagramControllerApi,ProcessInstanceTasksControllerApi, andProcessInstanceVariableControllerApi)
  • QueryTaskAdminService: APA Query Task Admin API (it includesTaskAdminControllerApi, andTaskVariableAdminControllerApi)
  • QueryTaskService: APA Query Task API (it includesTaskControllerApi, andTaskVariableControllerApi)

For example:

const queryProcessInstanceAdminService = new QueryProcessInstanceAdminService();queryProcessInstanceAdminService.findById('idProcess');

Form API

The following API is currently supported:

  • FormApi

You can use the following name to perform all the actions related to the API indicated above:

  • FormService: APA Form API (it includesFormApi)

For example:

const formId = variables.formId;const formService = new FormService();const form = formService.getFormDefinition(formId);

Actions

The actions that can be run against a script are:

ActionDescription
Download scriptDownload the bin file for the script.
ValidateRun validation against the script. Any errors can be seen in the log history at the bottom of the Modeling Application and are flagged in a pop-up box.
SaveSave any changes made to the script.
DeleteDelete the script.

Edit this page

Suggest an edit on GitHub
By clicking "Accept Cookies", you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.View Cookie Policy.

[8]ページ先頭

©2009-2025 Movatter.jp