You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

This server-side class provide methods and public functions that allow operating with workflows and theirs components, such as activities, transitions, and so on.

You can create an instance of the SimpleWorkflow class in the way described below:


SimpleWorkflow
    const workflow = new SimpleWorkflow('159491114038814558');

Parameter(s):

NameTypeMandatoryDefault Value
workflowIdIntegerNNULL

cancel(current)


This method allows cancelling all active contexts of the current record.


Parameter(s):

NameTypeMandatoryDefault Value
currentSimpleRecord objectYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

cancel
    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:

TypeDescription
SimpleRecord object or NULLThis method returns NULL if the new SimpleWorkflow object has been created without specifying the workflowId parameter; otherwise, it returns an object of the Workflow (wf_workflow) table (of a SimpleRecord type).


Example:

copy
   	const copiedWorkflow = SimpleWorkflow.copy();
   	const simpleWorkflow = new SimpleWorkflow(copiedWorkflow.sys_id);

delete()


This method deletes the workflow and all its elements.


Return:

TypeDescription
BooleanThis method returns the boolean result (TRUE if the workflow was successful deleted; otherwise, returns FALSE).


Example:

delete
   	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):

NameTypeMandatoryDefault Value
currentSimplerecord objectYN


Return:

TypeDescription
BooleanThis method returns the boolean result (TRUE if the active workflow context presents; otherwise, returns FALSE).


Example:

hasActiveContext
    if (simpleWorkflow.hasActiveContexts(current)) {
    	simpleWorkflow.cancel(current);
    }

revival(executingActivity, current)


This method restarts the workflow starting with the activity specified.


Parameter(s):

NameTypeMandatoryDefault Value
executingActivitySimplerecord objectYN
currentSimplerecord objectYN


Return:

TypeDescription
SimpleRecord objectThis method returns an object of the Workflow Context (wf_context) table (of a SimpleRecord type).


Example:

revival
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):

NameTypeMandatoryDefault Value
currentSimpleRecord objectYN


Return:

TypeDescription
SimpleRecord object or NULL

This method returns NULL in the cases listed below:

  • the new SimpleWorkflow object has been created without specifying the workflowId parameter;
  • there are no workflow versions created by the current user.

Otherwise, it returns an object of the Workflow Context (wf_context) table (of a SimpleRecord type). 


Example:

start
    let context = simpleWorkflow.start(current);
    if (context.state === 'finished') {
    	ss.info('Workflow finished!');
    }

startSubflow(executingActivity, current, workflowId)


This method allows starting sub-workflow by executing activity.


Parameter(s):

NameTypeMandatoryDefault Value
executingActivitySimpleRecord objectYN
currentSimpleRecord objectYN
workflowIdIntegerYN


Return:

TypeDescription
SimpleRecord object or NULLThis method returns NULL if there are no workflow versions created by the current user; otherwise, it returns an object of the Workflow Context (wf_context) table (of a SimpleRecord type). 


Example:

startSubflow

  • No labels