Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This server-side class provide methods and public functions that allow operating with workflows and theirs components, such as activities, transitions, and so on.
cancel(current)
This method allows cancelling all active contexts of the current record.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
current | SimpleRecord object | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (simpleWorkflow.hasActiveContexts(current)) { simpleWorkflow.cancel(current); } |
copy()
This method copies the workflow with creating a version in the Checked Out state and after that returns a copied workflow.
Return:
Type | Description |
---|---|
SimpleRecord object or NULL | This method returns NULL if the new SimpleWorkflow object has been created without specifying the workflowId parameter; otherwise, it returns the SimpleRecord object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
let copiedWorkflow = simpleWorkflow.copy(); let simpleWorkflow = new SimpleWorkflow(copiedWorkflow.sys_id); |
delete()
This method deletes the workflow and all its elements.
Return:
Type | Description |
---|---|
Boolean | This method returns the boolean result (TRUE if the workflow was successful deleted; otherwise, returns FALSE). |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
let copiedWorkflow = simpleWorkflow.copy(); let simpleWorkflow = new SimpleWorkflow(copiedWorkflow.sys_id); if (simpleWorkflow.delete()) { ss.info('Workflow deleted!'); } |
hasActiveContexts(current)
This method checks the current record if there are any active workflow contexts present or not.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
current | Simplerecord object | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns the boolean result (TRUE if the active workflow context presents; otherwise, returns FALSE). |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (simpleWorkflow.hasActiveContexts(current)) { simpleWorkflow.cancel(current); } |
revival(executingActivity, current)
This public function restarts method restarts the workflow starting with the activity specified.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
executingActivity | Simplerecord object | Y | N |
current | Simplerecord object | Y | N |
Return:
Type | Description |
---|---|
SimpleRecord object |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
let current = new SimpleRecord('task'); current.query(); current.next(); let activity = new SimpleRecord('wf_executing_activity'); activity.query(); activity.next(); let context = (new SimpleWorkflow())->revival(activity, current); |
start(current)
This method is intended to start the workflow.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
current | SimpleRecord object | Y | N |
Return:
Type | Description |
---|---|
SimpleRecord object or NULL | This method returns NULL if the new SimpleWorkflow object has been created without specifying the workflowId parameter; otherwise, it returns the SimpleRecord object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
let context = simpleWorkflow.start(current); if (context.state === 'finished') { ss.info('Workflow finished!'); } |
startSubflow(executingActivity, current, workflowId)
This public function allows method allows starting sub-workflow by executing activity.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
executingActivity | SimpleRecord object | Y | N |
current | SimpleRecord object | Y | N |
workflowId | Integer | Y | N |
Return:
Type | Description |
---|---|
SimpleRecord object or NULL | This method returns NULL is there are no workflow versions created by the current user; otherwise, returns the SimpleRecord object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Table of Contents | ||||
---|---|---|---|---|
|