Script Components are predefined scripts written for Script Tasks. All Script Components are found in the component tab in the left panel of the Process Studio.
Available script components
The following are the currently available script components:
-
Set Field Value - write static information or retrieved data within an instance to a form field.
-
Clear Field Value - automatically clear a Data Object form field from any connected form in your process model.
-
Copy all Fields - automatically copy multiple form field values from one or more forms to multiple form fields in any designated form.
-
Move to Folder - to automatically move a form from the instance root directory or any other created directory to any specified location.
-
Rename Form - automatically rename a form in your process model either by custom data or data collected from any connected form.
-
Set Instance Name - change the name of the current instance at any point during your workflow.
-
Unassign Role - clear a selected role of any assigned user or group.
-
Assign Role From Form Field - Automatically assigns an available user in Process Automation to a selected role.
- Generate Document from Template - Generates a word document or a PDF file with data from Process Automation form fields based on a .docx template.
The maximum number of script components you can have on one task is 35. It is recommended to not use more than 10 script components on one task.
Scripts with reading and writing purpose
All data needed in the script has to be available for the Script Task. Data in Process Automation is either managed in variables or in Data Objects. Variables are always available globally in each instance, therefore you do not need to prepare anything if only variables are handled in the script. If you are using data or fields in Data Objects, on the other hand, you will need to enable them for the Script Task. If the script will catch data from a Data Object it needs to be put as an input to the task and if the script will write to a Data Object it needs to be put as an output to the task. Read more about input/outputs in the article Add forms to your process.
A Script Task can only ever have one data output. If you wish to affect multiple Data Objects, you need to add more Script Tasks.
You can read more about the variables in this article.
Assign role from form field
Assign role from form field is a Script Component that allows you to assign a user to a role in your process provided that the user's email address has been entered into a connected data object form field and that the selected user is part of a group mapped to the role. This field must be of the type textfield, textarea, or single select and only one email address is supported.
This is useful for when you wish to allow the value of a field to dictate what user is assigned to a specific role.
Add the Assign role from form field component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Assign role from form field onto your canvas and attach a data object to it containing a field with an email address corresponding to a user in Process Automation.
The direction of the dataID should be set to "input".
- Open the script task settings and click on Configure scripts to open the configuration view.
- Select the role you wish to assign, any roles present in the process will show up in the drop-down list regardless of where you have placed your script component. Then, select the field where the email address you wish to collect is located.
- Select save.
If the script will catch data from a Data Object, it needs to be put as an input to the task. Read more about input/outputs in the article Add forms to your process.
Clear field value
Clear field value is a Script Component that automatically clears a Data Object form field in your process model.
For example, if a field value (such as a cost suggestion) has been filled in and later rejected and the data object has been sent back in a loop in order to receive a completely new value for that form field, it is more efficient if the rejected form field value is cleared allowing for new input.
Add the Clear field value component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Clear Field Value onto your canvas or onto an already existing script component of any type if you want to stack several scripts in one task. Close the configuration window and connect the Script Task to your other symbols as well as to any Form Templates and Data Objects (as output) you want to Clear Field Values in.
- Open the script task settings and click on Configure scripts to open the configuration view .
- Choose what form field you would like to clear. A drop-down list will be shown containing all fields available for clearing in the connected form.
The connected Form Template or Data Object must be set as an output to the Script Task in order to Clear Field Value. Furthermore, only one output connection is allowed per script task.
- Select Save.
How to clear multiple fields in the same Script Task
If you want to clear more than one field in that specific form, simply drag and drop one or more additional Script Components from the Component section in the Asset Browser onto your existing Script Task and configure your second script component. All added components will be accessible from the left-side menu in the Configure Script setting.
A script component can only ever have one output data object connected to it which means that if you'd like to clear fields in several different forms, a new script task is required for each new form.
You can also drag and drop the Script Component onto an already existing task in your process to transform it to a Script Task with the Script Component set on it. However, a script task can only ever be a script task and any other functionality the task originally had will not be available.
Copy all fields
Copy all fields is a Script Component that automatically copies multiple values from one form to multiple form fields in another form. This is useful for automating steps in process applications when you would like to copy all values from one form to another.
In order to copy all fields, the receiving form must have the same field names and be of the same field type as the particular field names in the form you wish to copy values from.
Only fields with corresponding field names and types will receive new values when Copy all fields is performed.
Add the Copy all fields component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Copy all Fields onto your canvas.
- Close the configuration window, add the new Script Task to your model and connect all Form Templates and Data Objects you want to set and get values to and from.
The Form Template or Data Object you wish to copy from must be an input while the Form Template or Data Object you wish to copy to must be an output. It is possible to have several inputs in which case you must select which Form Template or Data Object you would like to use from a drop-down list in the Configure script settings. There can only be one output from a script task.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Choose what Form Template or Data Object you would like to copy data from and make sure you have connected the recipient form as an output. Furthermore, chose if you want to Overwrite existing values or not.
- Select Save.
How to copy multiple fields to a single form in the same Script Task
If you want to copy form fields from more than one source to the recipient form, drag and drop one or more additional Script Components from the Components section in the Asset Browser onto your existing Script Task and configure your second script component, which can be found under the first one on the left side of the Configure script panel. Just make sure the field names in the receiving form correspond with the field names in the forms you wish to copy data from.
You can also drag and drop the Script Component onto an already existing Task in your process to transform it to a Script Task with the Script Component set on it. However, a script task can only ever be a script task and any functionality the task originally had will not be available.
Generate a document from a template
Generate document from a template is a Script Component that allows you to write data from Process Automation into a Word Document template (.docx) by using variables.
If the document includes images, they must be in one of the accepted formats to ensure a successful conversion.
Accepted formats: .jpeg, . jpg, .gif, and .png
Add the Generate document from template component to a process
- Open the Components section in the panel on the left side of Process Studio
- Drag and drop the component Generate document from template to your canvas.
- Incorporate the Script Task with your model and connect the word document template (.docx) you want to use. Make sure that you have a form object connected as an input to the script task.
See this article about how you create a word document that will contain variables for your document to set data to the document.
- Right-click on the word template to configure it.
The file name you create in the custom name will be the name saved to your file. In order for this to work, you need to take naming rules into consideration. The filename cannot contain any of the following characters:
<
left angle bracket
@
at sign
>
right angle bracket
+
plus sign
*
asterisk
`
backtick
?
question mark
|
pipe
/
forward slash
=
equal sign
blank spaces
%
percent
$
dollar sign
&
ampersand
!
exclamation mark
{
left curly bracket
'
single quotes
}
right curly bracket
"
double quotes
\
backslash
:
colon
1. By activating Move generated document you can specify in what folder you want to store your document. You can also set a custom name for the document.
2. By turning on Generate PDF from the document template, the document will be generated as a .PDF instead of a .docx.
Move to folder
Move to folder is a Script Component that allows you to automatically move a form from the instance root directory or any other created directory to a specified location. This is useful for organizing your forms into different folders.
Add the Move to folder component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Move to Folder onto your canvas.
- Close the configuration window, incorporate the Script Task to your model and connect the Form Template and/or Data Object you want to move.
The Form Template and/or Data Object you wish to move can be connected either as an input OR an output, the direction of the arrow does not matter in this case as no data is collected or altered within the form itself. However, there can still only be one output from a script task.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Choose what Form Template or Data Object you would like to move and type in the directory you want to move it to. If the directory does not exist, it will be created.
- Select Save.
How to move multiple forms in the same Script Task
If you want to move more than one form to new directories, drag and drop one or more additional Script Components from the Component section in the Asset Browser onto your existing Script Task and configure your second script component which can be found under the first on the left side of the Configure script panel. All connected forms will be shown as alternatives to choose from in the drop-down list.
You can also drag and drop the Script Component onto an already existing Task in your process to transform it to a Script Task with the Script Component set on it. Note however that a script task can only ever be a script task and that any functionality the task originally had will not be available.
Rename form
Rename form is a Script Component that automatically renames a form in your process model.
This is useful for when a form might transition from one state to another, requiring it to change names.
Add the Rename form component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the Rename form component onto your canvas or onto an already existing script component of any type if you want to stack several scripts in one task.
- Close the configuration window and connect the Script Task to your other symbols as well as to any Form Templates and Data Objects you want to set and get values to and from.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Choose what form you would like to rename by connecting a corresponding Form Template or Data Object to your script task. A drop-down list will be shown containing all connected forms available for renaming.
The connected Form Templates or Data Objects can be either an input OR an output to the Script Task
- Select where to take the new value from. You have two choices: Data Object or Custom Value:
Data Object: Choose the data object and field you wish to collect the new name from in the drop-down lists.
If you want to use a new name from a Data Object, the data object must be connected as an input to the Script Task.
Custom Value: Here you can write variables or plain text that will be set to the form field.
Read more about variables in the article Variables.
- Select Save.
How to rename multiple forms in the same Script Task
If you want to rename more than one form, make sure those other Form Templates and/or Data Objects are connected to the script task, then drag and drop one or more additional Script Component from the Component Browser onto your existing Script Task and configure your second script component. All added components will be accessible from the menu on the left side in the Configure Script setting.
You can also drag and drop the Script Component onto an already existing Task in your process to transform it to a Script Task with the Script Component set on it. However, a script task can only ever be a script task and any functionality the task originally had will not be available.
Set field value
Set field value is a predefined script to use on Script Tasks that automatically set a value on a form field. This is useful for automating steps in process applications.
Add the Set field value component to a process
- Open the Components section in the panel on the left side of Process Studio.
- Drag and drop the component Set Field Value onto your canvas.
- Close the configuration window, add your new Script Task to your model, and connect all Form Templates and Data Objects you want to set and get values to and from.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Choose what Form Template or Data Object and what field you would like to set data to.
A drop-down list will be shown containing all available fields in the chosen form.
The Form Template or Data Object must be as an output to the Script Task.
- Select where to take the value from, either Data Object or Custom Value:
Data Object: Choose the data object and field you wish to collect the value from in the drop-down lists.
If you use Data Object, the object must be as an input to the Script Task.
Custom Value: Here you can write variables or plain text that will be set to the form field.
Read more about variables in the article Variables.
- Select Save.
How to set values to multiple form fields in the same Script Task
If you want to set more than one value, drag and drop another Script Component from the Components section in the Asset Browser onto your existing Script Task and configure your second script component.
You can also drag and drop the Script Component onto an already existing Task in your process to transform it to a Script Task with the Script Component set on it.
Valid combinations from one field to another
When setting a value from one field to another, these are valid combinations.
All the fields of the same type can be combined. Example: FileUpload to FileUpload.
The (x) shows the valid combinations that do not have the same type.
To |
|||
From |
HTML editor |
Textarea |
Textfield |
Datefield |
x |
x |
x |
HTML editor |
x |
||
Numberfield |
x |
x |
x |
Numericfield |
x |
x |
x |
Textarea |
x |
x |
x |
Textfield |
x |
x |
x |
Timefield |
x |
x |
x |
To |
||||
From |
Standard Value List |
Standard Value List |
Extended value list (single) |
Extended value list (multi) |
Standard Value List (single) |
x |
x* |
x* |
x* |
Standard Value List (multi) |
x |
x* |
||
Extended value list (single) |
x* |
x* |
x |
x* |
Extended value list (multi) |
x* |
x |
*only if referring to the same value list namespace (ID)
Set instance description
Set Instance Name is a Script Component that allows you to change the description of an instance as an automated step in the process.
This is useful when you wish to use the instance description to show the status or other information.
Add the Set Instance Description component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Set Instance Description onto your canvas.
- Close the configuration window, incorporate the new Script Task to your model and connect any Form Templates and/or Data Objects you want to collect the new instance description from.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Select where to take the value from, either Data Object or Custom Value.
Data Object: Choose the data object and field you wish to collect the value from in the drop-down lists.
If you use Data Object, the object must be an input to the Script Task. Furthermore, you can only collect field value from a text field. If you want to use for example a number field you must use Custom Value with variables (see below).
Custom Value: Here you can write variables or plain text that will be set as the new instance name.
Read more about variables in the article Variables.
- Select Save.
Set Instance Name
Set Instance Name is a Script Component that allows you to change the name of an instance at any point during your process.
This is useful when you wish to change the name of the instance. Example: Adding a prefix to instances depending on their end state.
Add the Set instance name component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Set Instance Name onto your canvas.
- Close the configuration window, incorporate the new Script Task to your model and connect any Form Templates and/or Data Objects you might wish to collect the new instance name from.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Select where to take the value from, either Data Object or Custom Value:
Data Object: Choose the data object and field you wish to collect the value from in the drop-down lists.
If you use Data Object, the object must be an input to the Script Task. Furthermore, you can only collect field value from a text field. If you want to use for example a number field you must use Custom Value with variables (see below).
Custom Value: Here you can write variables or plain text that will be set as the new instance name.
Read more about variables in the article Variables.
- Select Save.
Unassign Role
Unassign role is a Script Component that allows you to empty a role in your process of any assigned users at any desired point during your process.
This is useful when you wish to reset who is allowed to perform certain tasks. For example, a group is mapped to a specific role and lane and a user from this group is currently the chosen performer of any tasks connected to the role in this lane. At some point in the process, you want to reevaluate which user from this group is best suited to keep working on the tasks in that lane. Adding the Unassign Role component makes this easier by clearing any role of users or groups. This will allow you to make a fresh selection when it is time to assign someone the responsibility to perform the work associated with the role you just emptied.
Add the Unassign role component to a process
- Open the Components section in the panel on the left side of the modeler.
- Drag and drop the component Unassign Role onto your canvas.
- Open the script task settings and click on Configure scripts to open the configuration view.
- Select the role you wish to unassign.
Any roles present in the process will show up in the drop-down list regardless of where you've placed your script component.
- Select Save.
Comments
0 comments
Article is closed for comments.