PLM Scripting supports three types of scripts: action, condition, validation. In this post, let’s focus on the action script and its triggers.
Action scripts can be used to create items, edit item field values, update bill of materials, perform workflow transitions and so on. In my previous post, the script we created for the Hello World example is an action script used to update an item’s title to “Hello World”. An action script can be divided into on-create script, on-edit script, on-demand script, and workflow script according to how it is triggered.
Four kinds of action scripts
- A on-create script will be triggered after an item is created (by either UI or a script).
- A workspace can only have one on-create script.
- An action script can be assigned to multiple workspaces as the on-create script.
- A on-edit script will be triggered after any field value of an item (under Item Details tab) is modified.
- The changes made on the other tabs (Project Management, Relationships…) won’t trigger on-edit script.
- A workspace can only have one on-edit script.
- An action script can be assigned to multiple workspaces as the on-edit script.
- An on-demand script will be triggered by clicking the script icon in item’s page.
- The script icon is available only if the current item is not locked (which means there are workflow actions available for the current user).
- One workspace can only have multiple on-demand scripts.
- An action script can be assigned to multiple workspaces as on-demand script.
- A workflow action script will be triggered when a workflow action is performed on the transition which the script is assigned.
- A workflow transition can only have one workflow action script.
- An action script can be assigned to multiple workflow transitions.
Set up triggers
The action script in “Hello World” example is an on-demand script. In that post, we had seen how to configure the script into a workspace as on-demand script. The on-create and on-edit scripts can be set up in the same configuration page as below. [Administration -> Workspace Manager -> workspace -> Behaviors]
The workflow action script can be set up for a transition in the Workflow Editor page as below. [Administration -> Workspace Manager -> workspace –> Workflow Editor]